diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index f08ca5f227c422..fc1764866daf21 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -51,6 +51,11 @@ jobs: run: | apt-get update DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing openjdk-17-jre + # Clean out java generated files: since java codegen will generate one file per + # structure/cluster, if clusters and structures are ever changed (for in progress work) + # this may leave obsolete files. Ensure we always check for clean regen. + - name: Ensure clean java + run: rm -rf src/controller/java/generated/ - name: Generate all run: ./scripts/run_in_build_env.sh scripts/tools/zap_regen_all.py - name: Generate script-maintained items (ERROR_CODES.md) diff --git a/docs/clusters.md b/docs/clusters.md index a3c4b13dee7271..8d1d29a84d2e87 100644 --- a/docs/clusters.md +++ b/docs/clusters.md @@ -77,6 +77,7 @@ Generally regenerate using one of: | 114 | 0x72 | ActivatedCarbonFilterMonitoring | | 128 | 0x80 | BooleanSensorConfiguration | | 129 | 0x81 | ValveConfigurationAndControl | +| 145 | 0x91 | ElectricalEnergyMeasurement | | 150 | 0x96 | DemandResponseLoadControl | | 152 | 0x98 | DeviceEnergyManagement | | 153 | 0x99 | EnergyEvse | diff --git a/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap b/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap index 9e6fd096b39361..987813f08a1cee 100644 --- a/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap +++ b/examples/air-purifier-app/air-purifier-common/air-purifier-app.zap @@ -7583,5 +7583,6 @@ "endpointId": 4, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.zap b/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.zap index 52d2ddfccc18f1..383705d04183cf 100644 --- a/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.zap +++ b/examples/air-quality-sensor-app/air-quality-sensor-common/air-quality-sensor-app.zap @@ -6063,5 +6063,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file 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 f405eed37f7c9c..d6345f8867dddd 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 @@ -3638,6 +3638,85 @@ cluster ActivatedCarbonFilterMonitoring = 114 { command ResetCondition(): DefaultSuccess = 0; } +/** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */ +provisional cluster ElectricalEnergyMeasurement = 145 { + revision 1; + + enum MeasurementTypeEnum : enum16 { + kUnspecified = 0; + kVoltage = 1; + kActiveCurrent = 2; + kReactiveCurrent = 3; + kApparentCurrent = 4; + kActivePower = 5; + kReactivePower = 6; + kApparentPower = 7; + kRMSVoltage = 8; + kRMSCurrent = 9; + kRMSPower = 10; + kFrequency = 11; + kPowerFactor = 12; + kNeutralCurrent = 13; + kElectricalEnergy = 14; + } + + bitmap Feature : bitmap32 { + kImportedEnergy = 0x1; + kExportedEnergy = 0x2; + kCumulativeEnergy = 0x4; + kPeriodicEnergy = 0x8; + } + + struct MeasurementAccuracyRangeStruct { + int64s rangeMin = 0; + int64s rangeMax = 1; + optional percent100ths percentMax = 2; + optional percent100ths percentMin = 3; + optional percent100ths percentTypical = 4; + optional int64u fixedMax = 5; + optional int64u fixedMin = 6; + optional int64u fixedTypical = 7; + } + + struct MeasurementAccuracyStruct { + MeasurementTypeEnum measurementType = 0; + boolean measured = 1; + int64s minMeasuredValue = 2; + int64s maxMeasuredValue = 3; + MeasurementAccuracyRangeStruct accuracyRanges[] = 4; + } + + struct EnergyMeasurementStruct { + int64s energy = 0; + optional epoch_s startTimestamp = 1; + optional epoch_s endTimestamp = 2; + optional systime_ms startSystime = 3; + optional systime_ms endSystime = 4; + } + + info event CumulativeEnergyMeasured = 0 { + optional EnergyMeasurementStruct energyImported = 0; + optional EnergyMeasurementStruct energyExported = 1; + } + + info event PeriodicEnergyMeasured = 1 { + optional EnergyMeasurementStruct energyImported = 0; + optional EnergyMeasurementStruct energyExported = 1; + } + + readonly attribute MeasurementAccuracyStruct accuracy = 0; + readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyImported = 1; + readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2; + readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3; + readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4; + 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; +} + /** Provides an interface for controlling and adjusting automatic window coverings. */ cluster WindowCovering = 258 { revision 5; @@ -7046,6 +7125,22 @@ endpoint 1 { handle command ResetCondition; } + server cluster ElectricalEnergyMeasurement { + emits event CumulativeEnergyMeasured; + emits event PeriodicEnergyMeasured; + callback attribute accuracy; + callback attribute cumulativeEnergyImported; + callback attribute cumulativeEnergyExported; + callback attribute periodicEnergyImported; + callback attribute periodicEnergyExported; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0x000F; + ram attribute clusterRevision default = 1; + } + server cluster WindowCovering { ram attribute type default = 0x08; ram attribute physicalClosedLimitLift default = 0xFFFF; 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 9d8216013aa144..2a331d5674f0e4 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 @@ -11524,6 +11524,225 @@ } ] }, + { + "name": "Electrical Energy Measurement", + "code": 145, + "mfgCode": null, + "define": "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", + "attributes": [ + { + "name": "Measured", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Accuracy", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "MeasurementAccuracyStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CumulativeEnergyImported", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CumulativeEnergyExported", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PeriodicEnergyImported", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PeriodicEnergyExported", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "EnergyMeasurementStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "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": null, + "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": null, + "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": null, + "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": null, + "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": "0x000F", + "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": "CumulativeEnergyMeasured", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "PeriodicEnergyMeasured", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Window Covering", "code": 258, @@ -21742,4 +21961,4 @@ } ], "log": [] -} \ No newline at end of file +} diff --git a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn index 97ca8d972051a4..9b5fd07f4b6893 100644 --- a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn +++ b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn @@ -37,7 +37,6 @@ ti_sysconfig("sysconfig") { sources = [ "${project_dir}/chip.syscfg" ] outputs = [ - "ti_devices_config.c", "ti_radio_config.c", "ti_radio_config.h", "ti_drivers_config.c", @@ -47,6 +46,10 @@ ti_sysconfig("sysconfig") { "ti_dmm_application_policy.c", "ti_dmm_application_policy.h", + # CCFG generation disabled for OTA-able application + #"ti_devices_config.c", + #"ti_devices_config.h", + # disabled until upstream generation is aligned #"tiop_config.h", #"tiop_config.c", diff --git a/examples/all-clusters-app/cc13x4_26x4/README.md b/examples/all-clusters-app/cc13x4_26x4/README.md index ad8581b52cf26c..f5a355f249c8aa 100644 --- a/examples/all-clusters-app/cc13x4_26x4/README.md +++ b/examples/all-clusters-app/cc13x4_26x4/README.md @@ -164,8 +164,8 @@ the session. Select the ELF image to load on the device with the `Browse` button. This file is placed in the `out/debug` folder by this guide and ends with the `*.out` file extension. For OTA enabled applications, the standalone image will instead end -with the `*-bim.hex` file extension. This this is a combined image with -application and and `BIM` included. The flag to enable or disable the OTA +with the `*-mcuboot.hex` file extension. This this is a combined image with +application and `MCUBoot` included. The flag to enable or disable the OTA feature is determined by "chip_enable_ota_requestor" in the application's args.gni file. diff --git a/examples/all-clusters-app/cc13x4_26x4/args.gni b/examples/all-clusters-app/cc13x4_26x4/args.gni index 5d97a9ca72d768..7c2e2acc9ae809 100644 --- a/examples/all-clusters-app/cc13x4_26x4/args.gni +++ b/examples/all-clusters-app/cc13x4_26x4/args.gni @@ -27,7 +27,7 @@ ti_simplelink_board = "LP_EM_CC1354P10_6" optimize_debug_level = "s" lwip_debug = false -chip_enable_ota_requestor = false +chip_enable_ota_requestor = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" chip_openthread_ftd = true @@ -49,4 +49,4 @@ chip_stack_lock_tracking = "none" matter_device_vid = "0xFFF1" matter_device_pid = "0x8006" matter_software_ver = "0x0001" -matter_software_ver_str = "1.0d1" +matter_software_ver_str = "1.0.1+1" diff --git a/examples/all-clusters-app/cc13x4_26x4/chip.syscfg b/examples/all-clusters-app/cc13x4_26x4/chip.syscfg index e9cb55c3e22f07..0257d3ed152e5e 100644 --- a/examples/all-clusters-app/cc13x4_26x4/chip.syscfg +++ b/examples/all-clusters-app/cc13x4_26x4/chip.syscfg @@ -83,7 +83,8 @@ for(var setting in ccfgSettings) CCFG[setting] = ccfgSettings[setting]; } -CCFG.enableCodeGeneration = true; +/* disable CCFG for OTA-able application */ +CCFG.enableCodeGeneration = false; /* NVS */ diff --git a/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp b/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp index 314ac6edd9adb4..1ab7b33a03c846 100644 --- a/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp +++ b/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #endif #include #include diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 2687ad0da28539..1be7ef7cd6c842 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -84,8 +84,9 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/temperature-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/dishwasher-alarm-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-energy-measurement-server" ) diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index f8242628a7b01e..2ca83ff224c938 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -12252,5 +12252,6 @@ "endpointId": 65534, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/bridge-app/asr/subdevice/subdevice_test.cpp b/examples/bridge-app/asr/subdevice/subdevice_test.cpp index c173e9b2b5da75..ea2411d4ba897e 100644 --- a/examples/bridge-app/asr/subdevice/subdevice_test.cpp +++ b/examples/bridge-app/asr/subdevice/subdevice_test.cpp @@ -93,10 +93,10 @@ constexpr CommandId onOffIncomingCommands[] = { }; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), - DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - // DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, nullptr, nullptr) - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, +DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + // DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr) + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint diff --git a/examples/bridge-app/bridge-common/bridge-app.zap b/examples/bridge-app/bridge-common/bridge-app.zap index 0412a216ba7872..daeb971c0c9b48 100644 --- a/examples/bridge-app/bridge-common/bridge-app.zap +++ b/examples/bridge-app/bridge-common/bridge-app.zap @@ -5753,5 +5753,6 @@ "endpointId": 2, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/bridge-app/esp32/README.md b/examples/bridge-app/esp32/README.md index 891a93d81a2892..ac22c7f8b3a424 100644 --- a/examples/bridge-app/esp32/README.md +++ b/examples/bridge-app/esp32/README.md @@ -62,7 +62,7 @@ defined: application's `main.cpp` for an example of this implementation. `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` -`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands)` +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands)` `DECLARE_DYNAMIC_CLUSTER_LIST_END` - These three macros are used to declare a list of clusters for use within a diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 62996518310533..41bca07f6fc9df 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -136,9 +136,9 @@ constexpr CommandId onOffIncomingCommands[] = { }; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), - DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, +DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint diff --git a/examples/bridge-app/linux/README.md b/examples/bridge-app/linux/README.md index 26d9aa1b11d211..a416923669eaee 100644 --- a/examples/bridge-app/linux/README.md +++ b/examples/bridge-app/linux/README.md @@ -53,7 +53,7 @@ defined: application's `main.cpp` for an example of this implementation. `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` -`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands)` +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands)` `DECLARE_DYNAMIC_CLUSTER_LIST_END` - These three macros are used to declare a list of clusters for use within a diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index f9edf960ded512..59f1514504c478 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -141,9 +141,9 @@ constexpr CommandId onOffIncomingCommands[] = { }; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), - DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, +DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint @@ -195,9 +195,9 @@ DECLARE_DYNAMIC_ATTRIBUTE(TemperatureMeasurement::Attributes::MeasuredValue::Id, // - Descriptor // - Bridged Device Basic Information DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedTempSensorClusters) -DECLARE_DYNAMIC_CLUSTER(TemperatureMeasurement::Id, tempSensorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), +DECLARE_DYNAMIC_CLUSTER(TemperatureMeasurement::Id, tempSensorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint @@ -224,9 +224,10 @@ DECLARE_DYNAMIC_ATTRIBUTE(PowerSource::Attributes::BatChargeLevel::Id, ENUM8, 1, DECLARE_DYNAMIC_ATTRIBUTE(PowerSource::Attributes::FeatureMap::Id, BITMAP32, 4, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedComposedDeviceClusters) -DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(PowerSource::Id, powerSourceAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(PowerSource::Id, powerSourceAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(bridgedComposedDeviceEndpoint, bridgedComposedDeviceClusters); DataVersion gComposedDeviceDataVersions[ArraySize(bridgedComposedDeviceClusters)]; diff --git a/examples/bridge-app/telink/README.md b/examples/bridge-app/telink/README.md index 34e99505c11f4b..1e24fc7fd92b2d 100644 --- a/examples/bridge-app/telink/README.md +++ b/examples/bridge-app/telink/README.md @@ -64,7 +64,7 @@ defined: application's `main.cpp` for an example of this implementation. `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` -`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands)` +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands)` `DECLARE_DYNAMIC_CLUSTER_LIST_END` - These three macros are used to declare a list of clusters for use within a diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index eff00fe9cffebe..f5593247b976a9 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -130,10 +130,10 @@ constexpr CommandId onOffIncomingCommands[] = { }; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), - DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, - nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, + ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // ----------------------------Temperature sensor----------------------------------------------- DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(tempSensorAttrs) @@ -152,9 +152,10 @@ DECLARE_DYNAMIC_ATTRIBUTE(Clusters::TemperatureMeasurement::Attributes::Measured // - Descriptor // - Bridged Device Basic Information DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedTempSensorClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::TemperatureMeasurement::Id, tempSensorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), +DECLARE_DYNAMIC_CLUSTER(Clusters::TemperatureMeasurement::Id, tempSensorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, + nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap index 44e06c856968f8..9eae9ed03bec5c 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap @@ -4827,5 +4827,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.zap b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.zap index ddf9888809e6e9..029e03b3d6c8db 100644 --- a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.zap +++ b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.zap @@ -7876,5 +7876,6 @@ "endpointId": 5, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap index 7eb4f3081dc3d2..1225a520c5e2c2 100644 --- a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap +++ b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap @@ -6070,5 +6070,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } diff --git a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap index 272db06ab28ad4..9876380437e15b 100644 --- a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap +++ b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap @@ -3970,5 +3970,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap index 709b2d3d338aba..863849c072ec8f 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap @@ -3950,5 +3950,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap index 7b5a4b49f9810a..58b836ccf50f53 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap @@ -3132,5 +3132,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap index 6ccf72e82c653b..c8330dd1701340 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap @@ -3564,5 +3564,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_dishwasher_cc105034fe.zap b/examples/chef/devices/rootnode_dishwasher_cc105034fe.zap index 5bc8fb68715b8c..b43f3c763799ff 100644 --- a/examples/chef/devices/rootnode_dishwasher_cc105034fe.zap +++ b/examples/chef/devices/rootnode_dishwasher_cc105034fe.zap @@ -3565,5 +3565,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap index 96c60ff5453cd3..91b44423822875 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap @@ -3461,5 +3461,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap index edd39619401e94..1a8fa80a5068ab 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap @@ -4054,5 +4054,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap b/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap index f3b01c60689739..c73eb2c7d43b2d 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap @@ -3275,5 +3275,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap index 5fe9927c1a14ea..dbb444c612924f 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap @@ -3034,5 +3034,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_genericswitch_9866e35d0b.zap b/examples/chef/devices/rootnode_genericswitch_9866e35d0b.zap index d4f54512a7f13e..d4801ef3d48ab4 100644 --- a/examples/chef/devices/rootnode_genericswitch_9866e35d0b.zap +++ b/examples/chef/devices/rootnode_genericswitch_9866e35d0b.zap @@ -2438,5 +2438,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap index 139e739d9f8411..d796e78dcc17be 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap @@ -3639,5 +3639,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap index d93a61ea027e91..fd1801e7f923d0 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap @@ -3034,5 +3034,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.zap b/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.zap index 6b3b2859bc5f03..d9cd3825701630 100644 --- a/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.zap +++ b/examples/chef/devices/rootnode_laundrywasher_fb10d238c8.zap @@ -3401,5 +3401,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap index c01e3ca021db05..ffe1e4e9881e6f 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap @@ -3002,5 +3002,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap index 550bd5b467de59..01ee3e4be73b33 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap @@ -3018,5 +3018,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap index e39bd754aadf0c..5387f929b2e5d5 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap @@ -3474,5 +3474,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.matter b/examples/chef/devices/rootnode_onofflight_samplemei.matter index ace3dace3f80fb..9910342d11e89d 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.matter +++ b/examples/chef/devices/rootnode_onofflight_samplemei.matter @@ -1491,6 +1491,11 @@ cluster FixedLabel = 64 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set + fabric_sensitive info event PingCountEvent = 0 { + int32u count = 1; + fabric_idx fabricIndex = 254; + } + attribute boolean flipFlop = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1825,9 +1830,11 @@ endpoint 1 { } server cluster SampleMei { + emits event PingCountEvent; ram attribute flipFlop default = false; callback attribute generatedCommandList; callback attribute acceptedCommandList; + callback attribute eventList; callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.zap b/examples/chef/devices/rootnode_onofflight_samplemei.zap index 473df045095cdc..0bcd495ba65859 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.zap +++ b/examples/chef/devices/rootnode_onofflight_samplemei.zap @@ -3538,6 +3538,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "EventList", + "code": 65530, + "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": "AttributeList", "code": 65531, @@ -3586,6 +3602,15 @@ "maxInterval": 65534, "reportableChange": 0 } + ], + "events": [ + { + "name": "PingCountEvent", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } ] } ] @@ -3606,5 +3631,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap index 4172207e164fe8..330377146f46f4 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap @@ -3194,5 +3194,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap index 7dcde4698b9da4..09eb11f7af077e 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap @@ -3222,5 +3222,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap index d8a968333633c6..feeee30e560046 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap @@ -3044,5 +3044,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_pump_5f904818cc.zap b/examples/chef/devices/rootnode_pump_5f904818cc.zap index b8909b097aaaa0..7ad53ca3281b52 100644 --- a/examples/chef/devices/rootnode_pump_5f904818cc.zap +++ b/examples/chef/devices/rootnode_pump_5f904818cc.zap @@ -3577,5 +3577,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_pump_a811bb33a0.zap b/examples/chef/devices/rootnode_pump_a811bb33a0.zap index e41fb9daa1c1aa..23b03e5b5b9b45 100644 --- a/examples/chef/devices/rootnode_pump_a811bb33a0.zap +++ b/examples/chef/devices/rootnode_pump_a811bb33a0.zap @@ -3035,5 +3035,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.zap b/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.zap index 7aa39d37307947..eec3ee7aa0e156 100644 --- a/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.zap +++ b/examples/chef/devices/rootnode_refrigerator_temperaturecontrolledcabinet_temperaturecontrolledcabinet_ffdb696680.zap @@ -3825,5 +3825,6 @@ "endpointId": 3, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.zap b/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.zap index 636f37076589eb..8c2a294fa04525 100644 --- a/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.zap +++ b/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.zap @@ -3083,5 +3083,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.zap b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.zap index 2feee5a947ccf4..074ad1dde59509 100644 --- a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.zap +++ b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.zap @@ -3180,5 +3180,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.zap b/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.zap index 5659783ce4ece8..3f0152a6202989 100644 --- a/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.zap +++ b/examples/chef/devices/rootnode_smokecoalarm_686fe0dcb8.zap @@ -3117,5 +3117,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap index b6cd32c5f5895d..edcfb8493a67c2 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap @@ -3206,5 +3206,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap index b35d366285e564..1a8083d15c19dd 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap @@ -3018,5 +3018,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap index a63173975d4c2b..29f186daa70076 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap @@ -3849,5 +3849,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap index b91dfc2b141d36..3a9b598f1435ae 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap @@ -3510,5 +3510,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chef/devices/template.zap b/examples/chef/devices/template.zap index a67dae0c0fcec5..c53936a568b663 100644 --- a/examples/chef/devices/template.zap +++ b/examples/chef/devices/template.zap @@ -2724,5 +2724,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 7a652661616296..7a0b440ad536dc 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -70,6 +70,8 @@ static_library("chip-tool-utils") { "commands/discover/DiscoverCommand.cpp", "commands/discover/DiscoverCommissionablesCommand.cpp", "commands/discover/DiscoverCommissionersCommand.cpp", + "commands/icd/ICDCommand.cpp", + "commands/icd/ICDCommand.h", "commands/pairing/OpenCommissioningWindowCommand.cpp", "commands/pairing/OpenCommissioningWindowCommand.h", "commands/pairing/PairingCommand.cpp", @@ -100,6 +102,7 @@ static_library("chip-tool-utils") { public_deps = [ "${chip_root}/examples/common/tracing:commandline", + "${chip_root}/src/app/icd/client:manager", "${chip_root}/src/app/server", "${chip_root}/src/app/tests/suites/commands/interaction_model", "${chip_root}/src/controller/data_model", diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp index 163af90fdd6f78..7e721734cd1a80 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.cpp +++ b/examples/chip-tool/commands/common/CHIPCommand.cpp @@ -47,6 +47,9 @@ constexpr char kCDTrustStorePathVariable[] = "CHIPTOOL_CD_TRUST_STORE_PATH" const chip::Credentials::AttestationTrustStore * CHIPCommand::sTrustStore = nullptr; chip::Credentials::GroupDataProviderImpl CHIPCommand::sGroupDataProvider{ kMaxGroupsPerFabric, kMaxGroupKeysPerFabric }; +// All fabrics share the same ICD client storage. +chip::app::DefaultICDClientStorage CHIPCommand::sICDClientStorage; +chip::Crypto::RawKeySessionKeystore CHIPCommand::sSessionKeystore; namespace { @@ -100,13 +103,19 @@ CHIP_ERROR CHIPCommand::MaybeSetUpStack() ReturnLogErrorOnFailure(mOperationalKeystore.Init(&mDefaultStorage)); ReturnLogErrorOnFailure(mOpCertStore.Init(&mDefaultStorage)); + // chip-tool uses a non-persistent keystore. + // ICD storage lifetime is currently tied to the chip-tool's lifetime. Since chip-tool interactive mode is currently used for + // ICD commissioning and check-in validation, this temporary storage meets the test requirements. + // TODO: Implement persistent ICD storage for the chip-tool. + ReturnLogErrorOnFailure(sICDClientStorage.Init(&mDefaultStorage, &sSessionKeystore)); + chip::Controller::FactoryInitParams factoryInitParams; factoryInitParams.fabricIndependentStorage = &mDefaultStorage; factoryInitParams.operationalKeystore = &mOperationalKeystore; factoryInitParams.opCertStore = &mOpCertStore; factoryInitParams.enableServerInteractions = NeedsOperationalAdvertising(); - factoryInitParams.sessionKeystore = &mSessionKeystore; + factoryInitParams.sessionKeystore = &sSessionKeystore; // Init group data provider that will be used for all group keys and IPKs for the // chip-tool-configured fabrics. This is OK to do once since the fabric tables @@ -486,6 +495,8 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(CommissionerIdentity & identity, chip::Credentials::SetSingleIpkEpochKey(&sGroupDataProvider, fabricIndex, defaultIpk, compressed_fabric_id_span)); } + CHIPCommand::sICDClientStorage.UpdateFabricList(commissioner->GetFabricIndex()); + mCommissioners[identity] = std::move(commissioner); return CHIP_NO_ERROR; diff --git a/examples/chip-tool/commands/common/CHIPCommand.h b/examples/chip-tool/commands/common/CHIPCommand.h index ae906166f28fa5..3376e47ba0f20d 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.h +++ b/examples/chip-tool/commands/common/CHIPCommand.h @@ -25,6 +25,7 @@ #include "Command.h" #include +#include #include #include #include @@ -155,9 +156,10 @@ class CHIPCommand : public Command #endif // CONFIG_USE_LOCAL_STORAGE chip::PersistentStorageOperationalKeystore mOperationalKeystore; chip::Credentials::PersistentStorageOpCertStore mOpCertStore; - chip::Crypto::RawKeySessionKeystore mSessionKeystore; + static chip::Crypto::RawKeySessionKeystore sSessionKeystore; static chip::Credentials::GroupDataProviderImpl sGroupDataProvider; + static chip::app::DefaultICDClientStorage sICDClientStorage; CredentialIssuerCommands * mCredIssuerCmds; std::string GetIdentity(); diff --git a/examples/chip-tool/commands/icd/ICDCommand.cpp b/examples/chip-tool/commands/icd/ICDCommand.cpp new file mode 100644 index 00000000000000..f3b43cfce6497f --- /dev/null +++ b/examples/chip-tool/commands/icd/ICDCommand.cpp @@ -0,0 +1,69 @@ +/* + * 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 "ICDCommand.h" + +#include +#include + +using namespace ::chip; + +CHIP_ERROR ICDListCommand::RunCommand() +{ + app::ICDClientInfo info; + auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo(); + char icdSymmetricKeyHex[Crypto::kAES_CCM128_Key_Length * 2 + 1]; + + fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); + fprintf(stderr, " | %-75s |\n", "Known ICDs:"); + fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); + fprintf(stderr, " | %20s | %15s | %15s | %16s |\n", "Fabric Index:Node ID", "Start Counter", "Counter Offset", + "MonitoredSubject"); + + while (iter->Next(info)) + { + fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); + fprintf(stderr, " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 " | " ChipLogFormatX64 " |\n", + static_cast(info.peer_node.GetFabricIndex()), ChipLogValueX64(info.peer_node.GetNodeId()), + info.start_icd_counter, info.offset, ChipLogValueX64(info.monitored_subject)); + + static_assert(std::is_same::value, + "The following BytesToHex can copy/encode the key bytes from sharedKey to hexadecimal format, which only " + "works for RawKeySessionKeystore"); + Encoding::BytesToHex(info.shared_key.As(), Crypto::kAES_CCM128_Key_Length, + icdSymmetricKeyHex, sizeof(icdSymmetricKeyHex), chip::Encoding::HexFlags::kNullTerminate); + fprintf(stderr, " | Symmetric Key: %60s |\n", icdSymmetricKeyHex); + } + + fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); + + iter->Release(); + SetCommandExitStatus(CHIP_NO_ERROR); + return CHIP_NO_ERROR; +} + +void registerCommandsICD(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) +{ + const char * name = "ICD"; + + commands_list list = { + make_unique(credsIssuerConfig), + }; + + commands.RegisterCommandSet(name, list, "Commands for client-side ICD management."); +} diff --git a/examples/chip-tool/commands/icd/ICDCommand.h b/examples/chip-tool/commands/icd/ICDCommand.h new file mode 100644 index 00000000000000..b36d66a7dbfcb9 --- /dev/null +++ b/examples/chip-tool/commands/icd/ICDCommand.h @@ -0,0 +1,45 @@ +/* + * 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 "../common/CHIPCommand.h" +#include "commands/common/Commands.h" + +#include + +class ICDCommand : public CHIPCommand +{ +public: + ICDCommand(const char * commandName, CredentialIssuerCommands * credIssuerCmds, const char * description) : + CHIPCommand(commandName, credIssuerCmds, description) + {} + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); } +}; + +class ICDListCommand : public ICDCommand +{ +public: + ICDListCommand(CredentialIssuerCommands * credIssuerCmds) : + ICDCommand("list", credIssuerCmds, "List ICDs registed by this controller.") + {} + CHIP_ERROR RunCommand() override; +}; + +void registerCommandsICD(Commands & commands, CredentialIssuerCommands * credsIssuerConfig); diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 049c34e6aa84a5..e15be0a1e8ae3c 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -37,6 +37,8 @@ CHIP_ERROR PairingCommand::RunCommand() // Clear the CATs in OperationalCredentialsIssuer mCredIssuerCmds->SetCredentialIssuerCATValues(kUndefinedCATs); + mDeviceIsICD = false; + if (mCASEAuthTags.HasValue() && mCASEAuthTags.Value().size() <= kMaxSubjectCATAttributeCount) { CATValues cats = kUndefinedCATs; @@ -385,6 +387,16 @@ void PairingCommand::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err) } else { + // When ICD device commissioning fails, the ICDClientInfo stored in OnICDRegistrationComplete needs to be removed. + if (mDeviceIsICD) + { + CHIP_ERROR deleteEntryError = + CHIPCommand::sICDClientStorage.DeleteEntry(ScopedNodeId(mNodeId, CurrentCommissioner().GetFabricIndex())); + if (deleteEntryError != CHIP_NO_ERROR) + { + ChipLogError(chipTool, "Failed to delete ICD entry: %s", ErrorStr(err)); + } + } ChipLogProgress(chipTool, "Device commissioning Failure: %s", ErrorStr(err)); } @@ -395,6 +407,7 @@ void PairingCommand::OnICDRegistrationInfoRequired() { // Since we compute our ICD Registration info up front, we can call ICDRegistrationInfoReady() directly. CurrentCommissioner().ICDRegistrationInfoReady(); + mDeviceIsICD = true; } void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounter) @@ -404,8 +417,27 @@ void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounte chip::Encoding::BytesToHex(mICDSymmetricKey.Value().data(), mICDSymmetricKey.Value().size(), icdSymmetricKeyHex, sizeof(icdSymmetricKeyHex), chip::Encoding::HexFlags::kNullTerminate); - // TODO: Persist symmetric key. + app::ICDClientInfo clientInfo; + clientInfo.peer_node = ScopedNodeId(nodeId, CurrentCommissioner().GetFabricIndex()); + clientInfo.monitored_subject = mICDMonitoredSubject.Value(); + clientInfo.start_icd_counter = icdCounter; + + CHIP_ERROR err = CHIPCommand::sICDClientStorage.SetKey(clientInfo, mICDSymmetricKey.Value()); + if (err == CHIP_NO_ERROR) + { + err = CHIPCommand::sICDClientStorage.StoreEntry(clientInfo); + } + + if (err != CHIP_NO_ERROR) + { + CHIPCommand::sICDClientStorage.RemoveKey(clientInfo); + ChipLogError(chipTool, "Failed to persist symmetric key for " ChipLogFormatX64 ": %s", ChipLogValueX64(nodeId), + err.AsString()); + SetCommandExitStatus(err); + return; + } + ChipLogProgress(chipTool, "Saved ICD Symmetric key for " ChipLogFormatX64, ChipLogValueX64(nodeId)); ChipLogProgress(chipTool, "ICD Registration Complete for device " ChipLogFormatX64 " / Check-In NodeID: " ChipLogFormatX64 " / Monitored Subject: " ChipLogFormatX64 " / Symmetric Key: %s", diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 089467d4042dde..be4722228a2bc8 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -253,6 +253,7 @@ class PairingCommand : public CHIPCommand, uint64_t mDiscoveryFilterCode; char * mDiscoveryFilterInstanceName; + bool mDeviceIsICD; uint8_t mRandomGeneratedICDSymmetricKey[chip::Crypto::kAES_CCM128_Key_Length]; // For unpair @@ -260,4 +261,5 @@ class PairingCommand : public CHIPCommand, chip::Callback::Callback mCurrentFabricRemoveCallback; static void OnCurrentFabricRemove(void * context, NodeId remoteNodeId, CHIP_ERROR status); + void PersistIcdInfo(); }; diff --git a/examples/chip-tool/main.cpp b/examples/chip-tool/main.cpp index a1eb4646a9fd98..6a52941e8b8d9c 100644 --- a/examples/chip-tool/main.cpp +++ b/examples/chip-tool/main.cpp @@ -23,6 +23,7 @@ #include "commands/delay/Commands.h" #include "commands/discover/Commands.h" #include "commands/group/Commands.h" +#include "commands/icd/ICDCommand.h" #include "commands/interactive/Commands.h" #include "commands/pairing/Commands.h" #include "commands/payload/Commands.h" @@ -40,6 +41,7 @@ int main(int argc, char * argv[]) Commands commands; registerCommandsDelay(commands, &credIssuerCommands); registerCommandsDiscover(commands, &credIssuerCommands); + registerCommandsICD(commands, &credIssuerCommands); registerCommandsInteractive(commands, &credIssuerCommands); registerCommandsPayload(commands); registerCommandsPairing(commands, &credIssuerCommands); diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap index 748e5b6f9bbc0a..b37968d2d15978 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap @@ -4746,5 +4746,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/dishwasher-app/dishwasher-common/dishwasher-app.zap b/examples/dishwasher-app/dishwasher-common/dishwasher-app.zap index 09ad0865018b8c..35bc463cd88416 100644 --- a/examples/dishwasher-app/dishwasher-common/dishwasher-app.zap +++ b/examples/dishwasher-app/dishwasher-common/dishwasher-app.zap @@ -3943,5 +3943,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImInvokeCommand.kt b/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImInvokeCommand.kt index f66c0d061343ce..5e80ef13daddb5 100644 --- a/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImInvokeCommand.kt +++ b/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImInvokeCommand.kt @@ -18,17 +18,11 @@ package com.matter.controller.commands.pairing import com.matter.controller.commands.common.CredentialsIssuer -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger import kotlinx.coroutines.runBlocking -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.model.CommandPath -import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.TlvWriter +import matter.controller.cluster.clusters.IdentifyCluster class PairOnNetworkLongImInvokeCommand( controller: MatterController, @@ -43,19 +37,6 @@ class PairOnNetworkLongImInvokeCommand( DiscoveryFilterType.LONG_DISCRIMINATOR ) { override fun runCommand() { - val IdentifyTime: UShort = 1u - val tlvWriter1 = TlvWriter() - tlvWriter1.startStructure(AnonymousTag) - tlvWriter1.put(ContextSpecificTag(0), IdentifyTime) - tlvWriter1.endStructure() - - val element1: InvokeRequest = - InvokeRequest( - CommandPath(endpointId = 0u, clusterId = CLUSTER_ID_IDENTIFY, commandId = IDENTIFY_COMMAND), - tlvPayload = tlvWriter1.getEncoded(), - timedRequest = Duration.ZERO - ) - currentCommissioner() .pairDevice( getNodeId(), @@ -69,11 +50,10 @@ class PairOnNetworkLongImInvokeCommand( runBlocking { try { - val response: InvokeResponse = currentCommissioner().invoke(element1) + val identifyTime: UShort = 1u + val identifyCluster = IdentifyCluster(controller = currentCommissioner(), endpointId = 0u) + identifyCluster.identify(identifyTime) logger.log(Level.INFO, "Invoke command succeeded") - if (response.payload.isNotEmpty()) { - // TODO:Handle TLV data response - } } catch (ex: Exception) { setFailure("invoke failure: ${ex.message}") } finally { @@ -86,11 +66,6 @@ class PairOnNetworkLongImInvokeCommand( companion object { private val logger = Logger.getLogger(PairOnNetworkLongImInvokeCommand::class.java.name) - private const val MATTER_PORT = 5540 - private const val CLUSTER_ID_IDENTIFY = 0x0003u - private const val IDENTIFY_COMMAND = 0u - private const val CLUSTER_ID_TEST = 0xFFF1FC05u - private const val TEST_ADD_ARGUMENT_COMMAND = 0X04u } } diff --git a/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImReadCommand.kt b/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImReadCommand.kt index 15cf62ed504067..ba4ae1ac938f2b 100644 --- a/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImReadCommand.kt +++ b/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImReadCommand.kt @@ -5,11 +5,7 @@ import java.util.logging.Level import java.util.logging.Logger import kotlinx.coroutines.runBlocking import matter.controller.MatterController -import matter.controller.ReadData -import matter.controller.ReadRequest -import matter.controller.ReadResponse -import matter.controller.model.AttributePath -import matter.controller.model.EventPath +import matter.controller.cluster.clusters.BasicInformationCluster class PairOnNetworkLongImReadCommand(controller: MatterController, credsIssue: CredentialsIssuer?) : PairingCommand( @@ -21,31 +17,6 @@ class PairOnNetworkLongImReadCommand(controller: MatterController, credsIssue: C DiscoveryFilterType.LONG_DISCRIMINATOR ) { override fun runCommand() { - val attributePaths = - listOf( - AttributePath( - endpointId = DEFAULT_ENDPOINT, - clusterId = CLUSTER_ID_BASIC, - attributeId = ATTR_ID_LOCAL_CONFIG_DISABLED, - ), - AttributePath( - endpointId = DEFAULT_ENDPOINT, - clusterId = CLUSTER_ID_BASIC, - attributeId = GLOBAL_ATTRIBUTE_LIST, - ) - ) - - val eventPaths = - listOf( - EventPath( - endpointId = WILDCARD_ENDPOINT_ID, - clusterId = WILDCARD_CLUSTER_ID, - eventId = WILDCARD_EVENT_ID - ) - ) - - val readRequest: ReadRequest = ReadRequest(eventPaths, attributePaths) - currentCommissioner() .pairDevice( getNodeId(), @@ -59,9 +30,11 @@ class PairOnNetworkLongImReadCommand(controller: MatterController, credsIssue: C runBlocking { try { - val response: ReadResponse = currentCommissioner().read(readRequest) - logger.log(Level.INFO, "Read command succeeded") - validateResponse(response) + val basicInformationCluster = + BasicInformationCluster(controller = currentCommissioner(), endpointId = DEFAULT_ENDPOINT) + val vendorName = basicInformationCluster.readVendorNameAttribute() + val vendorId = basicInformationCluster.readVendorIDAttribute() + logger.log(Level.INFO, "Read command succeeded, Verdor Name:${vendorName} (ID:${vendorId})") } catch (ex: Exception) { logger.log(Level.WARNING, "General read failure occurred with error ${ex.message}") setFailure("read failure") @@ -73,37 +46,9 @@ class PairOnNetworkLongImReadCommand(controller: MatterController, credsIssue: C setSuccess() } - private fun findAttributeById(successes: List, id: UInt): ReadData.Attribute? { - return successes.filterIsInstance().find { it.path.attributeId == id } - } - - private fun findEventById(successes: List, id: UInt): ReadData.Event? { - return successes.filterIsInstance().find { it.path.eventId == id } - } - - private fun validateResponse(response: ReadResponse) { - require(response.successes.isNotEmpty()) { "Unexpected: response.successes is empty" } - require(response.failures.isEmpty()) { "Unexpected: response.failures is not empty" } - - val localConfigDisabledAttribute = - findAttributeById(response.successes, ATTR_ID_LOCAL_CONFIG_DISABLED) - requireNotNull(localConfigDisabledAttribute) { "No local config disabled attribute found." } - - // TODO: Add more validation rules as needed - } - companion object { private val logger = Logger.getLogger(PairOnNetworkLongImReadCommand::class.java.name) - private const val MATTER_PORT = 5540 private const val DEFAULT_ENDPOINT: UShort = 0u - private const val WILDCARD_ENDPOINT_ID: UShort = 0xffffu - private const val WILDCARD_CLUSTER_ID: UInt = 0xffffffffu - private const val WILDCARD_ATTRIBUTE_ID: UInt = 0xffffffffu - private const val WILDCARD_EVENT_ID: UInt = 0xffffffffu - private const val CLUSTER_ID_BASIC: UInt = 0x0028u - private const val ATTR_ID_LOCAL_CONFIG_DISABLED: UInt = 16u - private const val EVENT_ID_START_UP: UInt = 0u - private const val GLOBAL_ATTRIBUTE_LIST: UInt = 65531u } } diff --git a/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt b/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt index 04195a041adc22..f87d827a0bc32a 100644 --- a/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt +++ b/examples/kotlin-matter-controller/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt @@ -18,17 +18,11 @@ package com.matter.controller.commands.pairing import com.matter.controller.commands.common.CredentialsIssuer -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger import kotlinx.coroutines.runBlocking import matter.controller.MatterController -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.model.AttributePath -import matter.tlv.AnonymousTag -import matter.tlv.TlvWriter +import matter.controller.cluster.clusters.BasicInformationCluster class PairOnNetworkLongImWriteCommand( controller: MatterController, @@ -43,25 +37,6 @@ class PairOnNetworkLongImWriteCommand( DiscoveryFilterType.LONG_DISCRIMINATOR ) { override fun runCommand() { - val tlvWriter1 = TlvWriter() - tlvWriter1.put(AnonymousTag, true) - val writeRequests: WriteRequests = - WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath( - endpointId = 0u, - clusterId = CLUSTER_ID_BASIC, - attributeId = ATTR_ID_LOCAL_CONFIG_DISABLED - ), - tlvPayload = tlvWriter1.getEncoded() - ) - ), - timedRequest = Duration.ZERO - ) - currentCommissioner() .pairDevice( getNodeId(), @@ -75,24 +50,13 @@ class PairOnNetworkLongImWriteCommand( runBlocking { try { - val response: WriteResponse = currentCommissioner().write(writeRequests) - - if (response is WriteResponse.Success) { - logger.log(Level.INFO, "Write command succeeded") - } else if (response is WriteResponse.PartialWriteFailure) { - logger.log( - Level.WARNING, - "Partial write failure occurred with ${response.failures.size} errors" - ) + val basicInformationCluster = + BasicInformationCluster(controller = currentCommissioner(), endpointId = DEFAULT_ENDPOINT) + basicInformationCluster.writeNodeLabelAttribute("Test Node Label") + logger.log(Level.INFO, "Write command succeeded") - for ((index, error) in response.failures.withIndex()) { - logger.log(Level.WARNING, "Error ${index + 1}:") - logger.log(Level.WARNING, "Attribute Path: ${error.attributePath}") - logger.log(Level.WARNING, "Exception Message: ${error.ex.message}") - } - - setFailure("invoke failure") - } + val nodeLabel = basicInformationCluster.readNodeLabelAttribute() + logger.log(Level.INFO, "Read command succeeded, NodeLabel:${nodeLabel}") } catch (ex: Exception) { setFailure("invoke failure: ${ex.message}") } catch (ex: Exception) { @@ -108,9 +72,7 @@ class PairOnNetworkLongImWriteCommand( companion object { private val logger = Logger.getLogger(PairOnNetworkLongImWriteCommand::class.java.name) - private const val MATTER_PORT = 5540 - private const val CLUSTER_ID_BASIC = 0x0028u - private const val ATTR_ID_LOCAL_CONFIG_DISABLED = 16u + private const val DEFAULT_ENDPOINT: UShort = 0u } } 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 478ce07cc7cb2d..354ba583cf0b41 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 @@ -5880,5 +5880,6 @@ "endpointId": 2, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.zap index 8e9a98042f426b..fcc53e79e4e132 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.zap @@ -4325,5 +4325,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap index f9491931a681af..88ba4b99a2bcb2 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap @@ -5301,5 +5301,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap index 31780199b9dace..2a827b20850429 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap @@ -4508,5 +4508,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/cc13x4_26x4/BUILD.gn b/examples/lighting-app/cc13x4_26x4/BUILD.gn index e2f105d8f85fed..8b24330ea346d2 100644 --- a/examples/lighting-app/cc13x4_26x4/BUILD.gn +++ b/examples/lighting-app/cc13x4_26x4/BUILD.gn @@ -45,8 +45,10 @@ ti_sysconfig("sysconfig") { "ti_ble_config.h", "ti_dmm_application_policy.c", "ti_dmm_application_policy.h", - "ti_devices_config.c", - "ti_devices_config.h", + + # CCFG generation disabled for OTA-able application + #"ti_devices_config.c", + #"ti_devices_config.h", # disabled until upstream generation is aligned #"tiop_config.h", diff --git a/examples/lighting-app/cc13x4_26x4/README.md b/examples/lighting-app/cc13x4_26x4/README.md index 2559c732dca70a..6d383e3e8f3be9 100644 --- a/examples/lighting-app/cc13x4_26x4/README.md +++ b/examples/lighting-app/cc13x4_26x4/README.md @@ -162,8 +162,8 @@ the session. Select the ELF image to load on the device with the `Browse` button. This file is placed in the `out/debug` folder by this guide and ends with the `*.out` file extension. For OTA enabled applications, the standalone image will instead end -with the `*-bim.hex` file extension. This this is a combined image with -application and and `BIM` included. The flag to enable or disable the OTA +with the `*-mcuboot.hex` file extension. This this is a combined image with +application and `MCUBoot` included. The flag to enable or disable the OTA feature is determined by "chip_enable_ota_requestor" in the application's args.gni file. diff --git a/examples/lighting-app/cc13x4_26x4/args.gni b/examples/lighting-app/cc13x4_26x4/args.gni index b3aabaa8d985ff..4292dcd7982393 100644 --- a/examples/lighting-app/cc13x4_26x4/args.gni +++ b/examples/lighting-app/cc13x4_26x4/args.gni @@ -27,7 +27,7 @@ ti_simplelink_board = "LP_EM_CC1354P10_6" optimize_debug_level = "s" lwip_debug = false -chip_enable_ota_requestor = false +chip_enable_ota_requestor = true chip_openthread_ftd = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" @@ -47,4 +47,4 @@ chip_stack_lock_tracking = "none" matter_device_vid = "0xFFF1" matter_device_pid = "0x8005" matter_software_ver = "0x0001" -matter_software_ver_str = "1.0d1" +matter_software_ver_str = "1.0.1+1" diff --git a/examples/lighting-app/cc13x4_26x4/chip.syscfg b/examples/lighting-app/cc13x4_26x4/chip.syscfg index e9cb55c3e22f07..0257d3ed152e5e 100644 --- a/examples/lighting-app/cc13x4_26x4/chip.syscfg +++ b/examples/lighting-app/cc13x4_26x4/chip.syscfg @@ -83,7 +83,8 @@ for(var setting in ccfgSettings) CCFG[setting] = ccfgSettings[setting]; } -CCFG.enableCodeGeneration = true; +/* disable CCFG for OTA-able application */ +CCFG.enableCodeGeneration = false; /* NVS */ diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index 5957a683589c26..adb2bafd84f577 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -41,7 +41,7 @@ #if CONFIG_ENABLE_ESP_INSIGHTS_SYSTEM_STATS #include -#define START_TIMEOUT_MS 600000 +#define START_TIMEOUT_MS 60000 #endif #if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index 66c0be9b94b739..854b16014cd6bf 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -5960,5 +5960,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.zap b/examples/lighting-app/nxp/zap/lighting-on-off.zap index 5be21734eee409..77fdb80b52a574 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.zap +++ b/examples/lighting-app/nxp/zap/lighting-on-off.zap @@ -3994,5 +3994,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/qpg/zap/light.zap b/examples/lighting-app/qpg/zap/light.zap index 2c881ce56c2e37..87e3bbcec961b4 100644 --- a/examples/lighting-app/qpg/zap/light.zap +++ b/examples/lighting-app/qpg/zap/light.zap @@ -5979,5 +5979,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap index 23c507509ea418..eb00551c566457 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap @@ -5932,5 +5932,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap index 768952dac2e36f..c5f5ddec752665 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap @@ -5076,5 +5076,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap index 8c4b29e926b2c7..52301cf0d9540e 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap @@ -3628,5 +3628,6 @@ "endpointId": 0, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lock-app/cc13x4_26x4/BUILD.gn b/examples/lock-app/cc13x4_26x4/BUILD.gn index 2aad7a5f06134b..d7ec4065ea098f 100644 --- a/examples/lock-app/cc13x4_26x4/BUILD.gn +++ b/examples/lock-app/cc13x4_26x4/BUILD.gn @@ -41,16 +41,14 @@ ti_sysconfig("sysconfig") { "ti_radio_config.h", "ti_drivers_config.c", "ti_drivers_config.h", - "ti_devices_config.c", - "ti_devices_config.h", "ti_ble_config.c", "ti_ble_config.h", "ti_dmm_application_policy.c", "ti_dmm_application_policy.h", - # disabled until upstream generation is aligned - #"tiop_config.h", - #"tiop_config.c", + # CCFG generation disabled for OTA-able application + #"ti_devices_config.c", + #"ti_devices_config.h", # not traditional source files #"ti_utils_build_linker.cmd.genlibs", diff --git a/examples/lock-app/cc13x4_26x4/README.md b/examples/lock-app/cc13x4_26x4/README.md index a230fbb8bd5fdd..eff189d68e5fcf 100644 --- a/examples/lock-app/cc13x4_26x4/README.md +++ b/examples/lock-app/cc13x4_26x4/README.md @@ -165,8 +165,8 @@ the session. Select the ELF image to load on the device with the `Browse` button. This file is placed in the `out/debug` folder by this guide and ends with the `*.out` file extension. For OTA enabled applications, the standalone image will instead end -with the `*-bim.hex` file extension. This this is a combined image with -application and and `BIM` included. The flag to enable or disable the OTA +with the `*-mcuboot.hex` file extension. This this is a combined image with +application and `MCUBoot` included. The flag to enable or disable the OTA feature is determined by "chip_enable_ota_requestor" in the application's args.gni file. diff --git a/examples/lock-app/cc13x4_26x4/args.gni b/examples/lock-app/cc13x4_26x4/args.gni index 1d6fca57730412..2db85d82d398d3 100644 --- a/examples/lock-app/cc13x4_26x4/args.gni +++ b/examples/lock-app/cc13x4_26x4/args.gni @@ -27,15 +27,15 @@ ti_simplelink_board = "LP_EM_CC1354P10_6" optimize_debug_level = "s" lwip_debug = false -chip_enable_ota_requestor = false +chip_enable_ota_requestor = true chip_openthread_ftd = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" # Disable CHIP Logging -#chip_progress_logging = false -#chip_detail_logging = false -#chip_automation_logging = false +chip_progress_logging = true +chip_detail_logging = true +chip_automation_logging = true # BLE options chip_config_network_layer_ble = true @@ -47,4 +47,5 @@ chip_stack_lock_tracking = "none" matter_device_vid = "0xFFF1" matter_device_pid = "0x8006" matter_software_ver = "0x0001" -matter_software_ver_str = "1.0d1" +matter_software_ver_str = "1.0.1+1" +# should be maj.min.rev+build with later parts optional for MCUBoot diff --git a/examples/lock-app/cc13x4_26x4/chip.syscfg b/examples/lock-app/cc13x4_26x4/chip.syscfg index e9cb55c3e22f07..0257d3ed152e5e 100644 --- a/examples/lock-app/cc13x4_26x4/chip.syscfg +++ b/examples/lock-app/cc13x4_26x4/chip.syscfg @@ -83,7 +83,8 @@ for(var setting in ccfgSettings) CCFG[setting] = ccfgSettings[setting]; } -CCFG.enableCodeGeneration = true; +/* disable CCFG for OTA-able application */ +CCFG.enableCodeGeneration = false; /* NVS */ diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index ef58c8006cb198..05016f2b4025af 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -6414,5 +6414,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lock-app/nxp/zap/lock-app.zap b/examples/lock-app/nxp/zap/lock-app.zap index bdb78c5307b26c..cc5c7a3bb3e194 100644 --- a/examples/lock-app/nxp/zap/lock-app.zap +++ b/examples/lock-app/nxp/zap/lock-app.zap @@ -3457,5 +3457,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lock-app/qpg/zap/lock.zap b/examples/lock-app/qpg/zap/lock.zap index d0489afe5c9b4b..07fc1197ddea91 100644 --- a/examples/lock-app/qpg/zap/lock.zap +++ b/examples/lock-app/qpg/zap/lock.zap @@ -5242,5 +5242,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/log-source-app/log-source-common/log-source-app.zap b/examples/log-source-app/log-source-common/log-source-app.zap index c486ee0070fea2..ac87b6dc41d924 100644 --- a/examples/log-source-app/log-source-common/log-source-app.zap +++ b/examples/log-source-app/log-source-common/log-source-app.zap @@ -737,5 +737,6 @@ "endpointId": 0, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/network-manager-app/network-manager-common/network-manager-app.zap b/examples/network-manager-app/network-manager-common/network-manager-app.zap index c6e8a0de50659d..3cac811850b8fc 100644 --- a/examples/network-manager-app/network-manager-common/network-manager-app.zap +++ b/examples/network-manager-app/network-manager-common/network-manager-app.zap @@ -170,7 +170,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -186,7 +186,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -202,7 +202,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -218,7 +218,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -234,7 +234,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -250,7 +250,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -266,7 +266,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -298,7 +298,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -324,7 +324,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -340,7 +340,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -356,7 +356,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -372,7 +372,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -388,7 +388,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -404,7 +404,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -420,7 +420,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -436,7 +436,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -468,7 +468,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -510,7 +510,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "10", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -526,7 +526,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -542,7 +542,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -558,7 +558,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -574,7 +574,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -606,7 +606,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "XX", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -622,7 +622,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -638,7 +638,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -654,7 +654,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -670,7 +670,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -686,7 +686,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "20210614123456ZZ", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -702,7 +702,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -718,7 +718,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -734,7 +734,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -750,7 +750,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -798,7 +798,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -814,7 +814,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -830,7 +830,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -846,7 +846,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -862,7 +862,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -878,7 +878,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -894,7 +894,7 @@ "storageOption": "External", "singleton": 1, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1041,7 +1041,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -1057,7 +1057,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1073,7 +1073,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1089,7 +1089,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1105,7 +1105,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1121,7 +1121,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1137,7 +1137,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1211,7 +1211,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1291,7 +1291,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1307,7 +1307,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1323,7 +1323,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1407,7 +1407,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -1423,7 +1423,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -1439,7 +1439,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000000000000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1455,7 +1455,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1471,7 +1471,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1487,7 +1487,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1503,7 +1503,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1519,7 +1519,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1551,7 +1551,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1567,7 +1567,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1583,7 +1583,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1671,7 +1671,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1687,7 +1687,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1703,7 +1703,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1719,7 +1719,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1735,7 +1735,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000000000000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1751,7 +1751,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1767,7 +1767,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1783,7 +1783,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1799,7 +1799,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1815,7 +1815,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1831,7 +1831,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1847,7 +1847,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1863,7 +1863,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1879,7 +1879,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1895,7 +1895,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1911,7 +1911,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1927,7 +1927,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1943,7 +1943,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1959,7 +1959,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1975,7 +1975,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -1991,7 +1991,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2059,7 +2059,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2075,7 +2075,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2091,7 +2091,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2107,7 +2107,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2123,7 +2123,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2139,7 +2139,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2155,7 +2155,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2171,7 +2171,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2187,7 +2187,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2203,7 +2203,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2219,7 +2219,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2235,7 +2235,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000000000000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2251,7 +2251,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000000000000000", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2342,7 +2342,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2358,7 +2358,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2374,7 +2374,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2450,7 +2450,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2466,7 +2466,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2482,7 +2482,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2498,7 +2498,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2514,7 +2514,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2530,7 +2530,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2686,7 +2686,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2702,7 +2702,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2718,7 +2718,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2734,7 +2734,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2750,7 +2750,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -2766,7 +2766,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2782,7 +2782,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2798,7 +2798,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2814,7 +2814,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2922,7 +2922,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2938,7 +2938,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2954,7 +2954,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2970,7 +2970,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2986,7 +2986,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3002,7 +3002,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3057,7 +3057,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3073,7 +3073,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3089,7 +3089,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3105,7 +3105,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3121,7 +3121,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3137,7 +3137,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3153,7 +3153,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3169,7 +3169,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3201,7 +3201,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap b/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap index 23becbb30ac9ed..3b5c806ab10d61 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap @@ -2315,5 +2315,6 @@ "endpointId": 0, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap index 37fb1e55071267..6665f50cd92c8b 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap @@ -3472,5 +3472,6 @@ "endpointId": 65534, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/placeholder/linux/apps/app1/config.zap b/examples/placeholder/linux/apps/app1/config.zap index 11f85e323bcf83..b7e4e02d1370cd 100644 --- a/examples/placeholder/linux/apps/app1/config.zap +++ b/examples/placeholder/linux/apps/app1/config.zap @@ -15141,5 +15141,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/placeholder/linux/apps/app2/config.zap b/examples/placeholder/linux/apps/app2/config.zap index 85b3958dde6f7e..c821c18390ea66 100644 --- a/examples/placeholder/linux/apps/app2/config.zap +++ b/examples/placeholder/linux/apps/app2/config.zap @@ -14933,5 +14933,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/pump-app/cc13x4_26x4/BUILD.gn b/examples/pump-app/cc13x4_26x4/BUILD.gn index 18865640fb3259..f3fc4384f69336 100644 --- a/examples/pump-app/cc13x4_26x4/BUILD.gn +++ b/examples/pump-app/cc13x4_26x4/BUILD.gn @@ -36,7 +36,6 @@ ti_sysconfig("sysconfig") { sources = [ "${project_dir}/chip.syscfg" ] outputs = [ - "ti_devices_config.c", "ti_radio_config.c", "ti_radio_config.h", "ti_drivers_config.c", @@ -46,6 +45,10 @@ ti_sysconfig("sysconfig") { "ti_dmm_application_policy.c", "ti_dmm_application_policy.h", + # CCFG generation disabled for OTA-able application + #"ti_devices_config.c", + #"ti_devices_config.h", + # disabled until upstream generation is aligned #"tiop_config.h", #"tiop_config.c", diff --git a/examples/pump-app/cc13x4_26x4/README.md b/examples/pump-app/cc13x4_26x4/README.md index 7ad0521fef77de..23261b75cc575c 100644 --- a/examples/pump-app/cc13x4_26x4/README.md +++ b/examples/pump-app/cc13x4_26x4/README.md @@ -163,8 +163,8 @@ the session. Select the ELF image to load on the device with the `Browse` button. This file is placed in the `out/debug` folder by this guide and ends with the `*.out` file extension. For OTA enabled applications, the standalone image will instead end -with the `*-bim.hex` file extension. This this is a combined image with -application and and `BIM` included. The flag to enable or disable the OTA +with the `*-mcuboot.hex` file extension. This this is a combined image with +application and `MCUBoot` included. The flag to enable or disable the OTA feature is determined by "chip_enable_ota_requestor" in the application's args.gni file. diff --git a/examples/pump-app/cc13x4_26x4/args.gni b/examples/pump-app/cc13x4_26x4/args.gni index 6ce8fc0e1f0d90..66e2a5a2e64ed0 100644 --- a/examples/pump-app/cc13x4_26x4/args.gni +++ b/examples/pump-app/cc13x4_26x4/args.gni @@ -27,7 +27,7 @@ ti_simplelink_board = "LP_EM_CC1354P10_6" optimize_debug_level = "s" lwip_debug = false -chip_enable_ota_requestor = false +chip_enable_ota_requestor = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" chip_openthread_ftd = true @@ -47,4 +47,4 @@ chip_stack_lock_tracking = "none" matter_device_vid = "0xFFF1" matter_device_pid = "0x800A" matter_software_ver = "0x0001" -matter_software_ver_str = "1.0d1" +matter_software_ver_str = "1.0.1+1" diff --git a/examples/pump-app/cc13x4_26x4/chip.syscfg b/examples/pump-app/cc13x4_26x4/chip.syscfg index e9cb55c3e22f07..0257d3ed152e5e 100644 --- a/examples/pump-app/cc13x4_26x4/chip.syscfg +++ b/examples/pump-app/cc13x4_26x4/chip.syscfg @@ -83,7 +83,8 @@ for(var setting in ccfgSettings) CCFG[setting] = ccfgSettings[setting]; } -CCFG.enableCodeGeneration = true; +/* disable CCFG for OTA-able application */ +CCFG.enableCodeGeneration = false; /* NVS */ diff --git a/examples/pump-app/pump-common/pump-app.zap b/examples/pump-app/pump-common/pump-app.zap index 47060615ba022a..ace68aa46200d8 100644 --- a/examples/pump-app/pump-common/pump-app.zap +++ b/examples/pump-app/pump-common/pump-app.zap @@ -4654,5 +4654,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/pump-app/silabs/data_model/pump-thread-app.zap b/examples/pump-app/silabs/data_model/pump-thread-app.zap index 1759c693e901d0..3c2f4cb9bf9959 100644 --- a/examples/pump-app/silabs/data_model/pump-thread-app.zap +++ b/examples/pump-app/silabs/data_model/pump-thread-app.zap @@ -4654,5 +4654,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/pump-app/silabs/data_model/pump-wifi-app.zap b/examples/pump-app/silabs/data_model/pump-wifi-app.zap index 1759c693e901d0..3c2f4cb9bf9959 100644 --- a/examples/pump-app/silabs/data_model/pump-wifi-app.zap +++ b/examples/pump-app/silabs/data_model/pump-wifi-app.zap @@ -4654,5 +4654,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/pump-controller-app/cc13x4_26x4/BUILD.gn b/examples/pump-controller-app/cc13x4_26x4/BUILD.gn index 49fc1b270c7598..95fa5205a3dd67 100644 --- a/examples/pump-controller-app/cc13x4_26x4/BUILD.gn +++ b/examples/pump-controller-app/cc13x4_26x4/BUILD.gn @@ -37,7 +37,6 @@ ti_sysconfig("sysconfig") { sources = [ "${project_dir}/chip.syscfg" ] outputs = [ - "ti_devices_config.c", "ti_radio_config.c", "ti_radio_config.h", "ti_drivers_config.c", @@ -47,6 +46,10 @@ ti_sysconfig("sysconfig") { "ti_dmm_application_policy.c", "ti_dmm_application_policy.h", + # CCFG generation disabled for OTA-able application + #"ti_devices_config.c", + #"ti_devices_config.h", + # disabled until upstream generation is aligned #"tiop_config.h", #"tiop_config.c", diff --git a/examples/pump-controller-app/cc13x4_26x4/README.md b/examples/pump-controller-app/cc13x4_26x4/README.md index 15894f7d596323..a19c79697ddd79 100644 --- a/examples/pump-controller-app/cc13x4_26x4/README.md +++ b/examples/pump-controller-app/cc13x4_26x4/README.md @@ -164,8 +164,8 @@ the session. Select the ELF image to load on the device with the `Browse` button. This file is placed in the `out/debug` folder by this guide and ends with the `*.out` file extension. For OTA enabled applications, the standalone image will instead end -with the `*-bim.hex` file extension. This this is a combined image with -application and and `BIM` included. The flag to enable or disable the OTA +with the `*-mcuboot.hex` file extension. This this is a combined image with +application and `MCUBoot` included. The flag to enable or disable the OTA feature is determined by "chip_enable_ota_requestor" in the application's args.gni file. diff --git a/examples/pump-controller-app/cc13x4_26x4/args.gni b/examples/pump-controller-app/cc13x4_26x4/args.gni index 012565ce996f94..375ff1b7b08ffb 100644 --- a/examples/pump-controller-app/cc13x4_26x4/args.gni +++ b/examples/pump-controller-app/cc13x4_26x4/args.gni @@ -27,7 +27,7 @@ ti_simplelink_board = "LP_EM_CC1354P10_6" optimize_debug_level = "s" lwip_debug = false -chip_enable_ota_requestor = false +chip_enable_ota_requestor = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" chip_openthread_ftd = true @@ -47,4 +47,4 @@ chip_stack_lock_tracking = "none" matter_device_vid = "0xFFF1" matter_device_pid = "0x8011" matter_software_ver = "0x0001" -matter_software_ver_str = "1.0d1" +matter_software_ver_str = "1.0.1+1" diff --git a/examples/pump-controller-app/cc13x4_26x4/chip.syscfg b/examples/pump-controller-app/cc13x4_26x4/chip.syscfg index e9cb55c3e22f07..0257d3ed152e5e 100644 --- a/examples/pump-controller-app/cc13x4_26x4/chip.syscfg +++ b/examples/pump-controller-app/cc13x4_26x4/chip.syscfg @@ -83,7 +83,8 @@ for(var setting in ccfgSettings) CCFG[setting] = ccfgSettings[setting]; } -CCFG.enableCodeGeneration = true; +/* disable CCFG for OTA-able application */ +CCFG.enableCodeGeneration = false; /* NVS */ diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap b/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap index c62ef5889939b5..bba15f087cfdc6 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap @@ -3480,5 +3480,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/refrigerator-app/refrigerator-common/refrigerator-app.zap b/examples/refrigerator-app/refrigerator-common/refrigerator-app.zap index 2efab5f43b384c..b3da40044c69b3 100644 --- a/examples/refrigerator-app/refrigerator-common/refrigerator-app.zap +++ b/examples/refrigerator-app/refrigerator-common/refrigerator-app.zap @@ -3757,5 +3757,6 @@ "endpointId": 3, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/rvc-app/rvc-common/rvc-app.zap b/examples/rvc-app/rvc-common/rvc-app.zap index 9ab708e1bf0446..9f4f43bc793e3a 100644 --- a/examples/rvc-app/rvc-common/rvc-app.zap +++ b/examples/rvc-app/rvc-common/rvc-app.zap @@ -2823,5 +2823,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/shell/cc13x4_26x4/README.md b/examples/shell/cc13x4_26x4/README.md index 08be886e6fb86e..60b73447c5a7c8 100644 --- a/examples/shell/cc13x4_26x4/README.md +++ b/examples/shell/cc13x4_26x4/README.md @@ -121,8 +121,8 @@ the session. Select the ELF image to load on the device with the `Browse` button. This file is placed in the `out/debug` folder by this guide and ends with the `*.out` file extension. For OTA enabled applications, the standalone image will instead end -with the `*-bim.hex` file extension. This this is a combined image with -application and and `BIM` included. +with the `*-mcuboot.hex` file extension. This this is a combined image with +application and and `MCUBoot` included. Finally click the `Load Image` button to load the executable image onto the device. You should be able to see the log output over the XDS110 User UART. diff --git a/examples/shell/cc13x4_26x4/args.gni b/examples/shell/cc13x4_26x4/args.gni index 9f1f28f24147df..13e622146a320e 100644 --- a/examples/shell/cc13x4_26x4/args.gni +++ b/examples/shell/cc13x4_26x4/args.gni @@ -25,7 +25,7 @@ ti_simplelink_board = "LP_EM_CC1354P10_6" # use -Os instead of -Og, LWIP release build is_debug = false -chip_enable_ota_requestor = false +chip_enable_ota_requestor = true # Disable FTD Build for all-clusters app to save Flash chip_openthread_ftd = false @@ -48,4 +48,4 @@ chip_stack_lock_tracking = "none" matter_device_vid = "0xFFF1" matter_device_pid = "0x8006" matter_software_ver = "0x0001" -matter_software_ver_str = "1.0d1" +matter_software_ver_str = "1.0.1+1" diff --git a/examples/shell/cc13x4_26x4/chip.syscfg b/examples/shell/cc13x4_26x4/chip.syscfg index 1648cae0ac4239..aca6b1dfcc5136 100644 --- a/examples/shell/cc13x4_26x4/chip.syscfg +++ b/examples/shell/cc13x4_26x4/chip.syscfg @@ -83,7 +83,8 @@ for(var setting in ccfgSettings) CCFG[setting] = ccfgSettings[setting]; } -CCFG.enableCodeGeneration = true; +/* disable CCFG for OTA-able application */ +CCFG.enableCodeGeneration = false; /* NVS */ diff --git a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap index e81864a5181d20..e80abb2729557a 100644 --- a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap +++ b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.zap @@ -4881,5 +4881,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap index 9803e8d34ec36a..924ca2e2ccc48d 100644 --- a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap +++ b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap @@ -3225,5 +3225,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/thermostat/nxp/zap/thermostat_matter_thread.zap b/examples/thermostat/nxp/zap/thermostat_matter_thread.zap index d5927370f28635..52062d89c75a08 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_thread.zap +++ b/examples/thermostat/nxp/zap/thermostat_matter_thread.zap @@ -4918,5 +4918,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/thermostat/nxp/zap/thermostat_matter_wifi.zap b/examples/thermostat/nxp/zap/thermostat_matter_wifi.zap index a4b725903ac7a1..035d087d09cab1 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_wifi.zap +++ b/examples/thermostat/nxp/zap/thermostat_matter_wifi.zap @@ -4060,5 +4060,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index 51d93649dce726..c5aebe739ad24b 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -5091,5 +5091,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/tv-app/android/java/AppImpl.cpp b/examples/tv-app/android/java/AppImpl.cpp index 91d177bba831b5..3c50d759d6900f 100644 --- a/examples/tv-app/android/java/AppImpl.cpp +++ b/examples/tv-app/android/java/AppImpl.cpp @@ -230,21 +230,22 @@ constexpr CommandId channelOutgoingCommands[] = { }; // Declare Cluster List for Content App endpoint DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(contentAppClusters) -DECLARE_DYNAMIC_CLUSTER(app::Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationBasic::Id, applicationBasicAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::KeypadInput::Id, keypadInputAttrs, keypadInputIncomingCommands, +DECLARE_DYNAMIC_CLUSTER(app::Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationBasic::Id, applicationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::KeypadInput::Id, keypadInputAttrs, ZAP_CLUSTER_MASK(SERVER), keypadInputIncomingCommands, keypadInputOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationLauncher::Id, applicationLauncherAttrs, applicationLauncherIncomingCommands, - applicationLauncherOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::AccountLogin::Id, accountLoginAttrs, accountLoginIncomingCommands, - accountLoginOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::ContentLauncher::Id, contentLauncherAttrs, contentLauncherIncomingCommands, - contentLauncherOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::MediaPlayback::Id, mediaPlaybackAttrs, mediaPlaybackIncomingCommands, - mediaPlaybackOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::TargetNavigator::Id, targetNavigatorAttrs, targetNavigatorIncomingCommands, - targetNavigatorOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::Channel::Id, channelAttrs, channelIncomingCommands, channelOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationLauncher::Id, applicationLauncherAttrs, ZAP_CLUSTER_MASK(SERVER), + applicationLauncherIncomingCommands, applicationLauncherOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::AccountLogin::Id, accountLoginAttrs, ZAP_CLUSTER_MASK(SERVER), + accountLoginIncomingCommands, accountLoginOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::ContentLauncher::Id, contentLauncherAttrs, ZAP_CLUSTER_MASK(SERVER), + contentLauncherIncomingCommands, contentLauncherOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::MediaPlayback::Id, mediaPlaybackAttrs, ZAP_CLUSTER_MASK(SERVER), + mediaPlaybackIncomingCommands, mediaPlaybackOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::TargetNavigator::Id, targetNavigatorAttrs, ZAP_CLUSTER_MASK(SERVER), + targetNavigatorIncomingCommands, targetNavigatorOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::Channel::Id, channelAttrs, ZAP_CLUSTER_MASK(SERVER), channelIncomingCommands, + channelOutgoingCommands), DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Content App endpoint diff --git a/examples/tv-app/tv-common/src/AppTv.cpp b/examples/tv-app/tv-common/src/AppTv.cpp index 9dc840af319a98..ae87badcbcc1e4 100644 --- a/examples/tv-app/tv-common/src/AppTv.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -393,21 +393,22 @@ constexpr CommandId channelOutgoingCommands[] = { }; // Declare Cluster List for Content App endpoint DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(contentAppClusters) -DECLARE_DYNAMIC_CLUSTER(app::Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationBasic::Id, applicationBasicAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::KeypadInput::Id, keypadInputAttrs, keypadInputIncomingCommands, +DECLARE_DYNAMIC_CLUSTER(app::Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationBasic::Id, applicationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::KeypadInput::Id, keypadInputAttrs, ZAP_CLUSTER_MASK(SERVER), keypadInputIncomingCommands, keypadInputOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationLauncher::Id, applicationLauncherAttrs, applicationLauncherIncomingCommands, - applicationLauncherOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::AccountLogin::Id, accountLoginAttrs, accountLoginIncomingCommands, - accountLoginOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::ContentLauncher::Id, contentLauncherAttrs, contentLauncherIncomingCommands, - contentLauncherOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::MediaPlayback::Id, mediaPlaybackAttrs, mediaPlaybackIncomingCommands, - mediaPlaybackOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::TargetNavigator::Id, targetNavigatorAttrs, targetNavigatorIncomingCommands, - targetNavigatorOutgoingCommands), - DECLARE_DYNAMIC_CLUSTER(app::Clusters::Channel::Id, channelAttrs, channelIncomingCommands, channelOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::ApplicationLauncher::Id, applicationLauncherAttrs, ZAP_CLUSTER_MASK(SERVER), + applicationLauncherIncomingCommands, applicationLauncherOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::AccountLogin::Id, accountLoginAttrs, ZAP_CLUSTER_MASK(SERVER), + accountLoginIncomingCommands, accountLoginOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::ContentLauncher::Id, contentLauncherAttrs, ZAP_CLUSTER_MASK(SERVER), + contentLauncherIncomingCommands, contentLauncherOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::MediaPlayback::Id, mediaPlaybackAttrs, ZAP_CLUSTER_MASK(SERVER), + mediaPlaybackIncomingCommands, mediaPlaybackOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::TargetNavigator::Id, targetNavigatorAttrs, ZAP_CLUSTER_MASK(SERVER), + targetNavigatorIncomingCommands, targetNavigatorOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(app::Clusters::Channel::Id, channelAttrs, ZAP_CLUSTER_MASK(SERVER), channelIncomingCommands, + channelOutgoingCommands), DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Content App endpoint diff --git a/examples/tv-casting-app/tv-casting-common/BUILD.gn b/examples/tv-casting-app/tv-casting-common/BUILD.gn index 4e87c59f118a99..c5ad03964cb0d9 100644 --- a/examples/tv-casting-app/tv-casting-common/BUILD.gn +++ b/examples/tv-casting-app/tv-casting-common/BUILD.gn @@ -110,6 +110,7 @@ chip_data_model("tv-casting-common") { deps = [ "${chip_root}/examples/common/tracing:commandline", + "${chip_root}/src/app/icd/client:manager", "${chip_root}/src/app/tests/suites/commands/interaction_model", "${chip_root}/src/lib/support/jsontlv", "${chip_root}/src/tracing", diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap index e2df7549c77b07..abe20a454df785 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap @@ -4414,5 +4414,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/virtual-device-app/virtual-device-common/virtual-device-app.zap b/examples/virtual-device-app/virtual-device-common/virtual-device-app.zap index ef2d710c43ba78..c386e4c4becfe7 100644 --- a/examples/virtual-device-app/virtual-device-common/virtual-device-app.zap +++ b/examples/virtual-device-app/virtual-device-common/virtual-device-app.zap @@ -6106,5 +6106,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index 58156ec9db2319..2a8bb37fe4ee4c 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -7105,5 +7105,6 @@ "endpointId": 2, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/kotlin-detect-config.yaml b/kotlin-detect-config.yaml index 3ca00b718ca139..5dcc9f99a6b3cd 100644 --- a/kotlin-detect-config.yaml +++ b/kotlin-detect-config.yaml @@ -233,6 +233,9 @@ exceptions: - "**/src/controller/java/generated/java/**/*" naming: + VariableNaming: + excludes: + - "**/src/controller/java/generated/java/**/*" FunctionNaming: excludes: - "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt" diff --git a/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py b/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py index ee13991f23d8df..5fa6f06482439c 100644 --- a/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py +++ b/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py @@ -498,6 +498,39 @@ def GetNextProcessor(self, name: str, attrs: AttributesImpl): return BaseHandler(self.context) +class RevisionHistoryHandler(BaseHandler): + """ + Parses elements of revision history that look like: + + ''' + + + + + + + ''' + """ + + def __init__(self, context: Context, cluster: Cluster): + super().__init__(context, handled=HandledDepth.SINGLE_TAG) + self._cluster = cluster + + def GetNextProcessor(self, name: str, attrs: AttributesImpl): + if name == "revision": + if 'revision' not in attrs: + LOGGER.error( + f"Could not find a revision for {attrs}: no revision data") + return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + else: + rev = int(attrs['revision']) + if self._cluster.revision < rev: + self._cluster.revision = rev + return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) + else: + return BaseHandler(self.context) + + class DataTypesHandler(BaseHandler): def __init__(self, context: Context, cluster: Cluster): super().__init__(context, handled=HandledDepth.SINGLE_TAG) @@ -580,12 +613,7 @@ def EndProcessing(self): def GetNextProcessor(self, name: str, attrs: AttributesImpl): if name == "revisionHistory": - # Revision history COULD be used to find the latest revision of a cluster - # however current IDL files do NOT have a revision info field - # - # NOTE: we COULD set this as a `default` for attribute clusterRevision, however this will likely - # not match with what matter IDL would parse into. - return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) + return RevisionHistoryHandler(self.context, self._cluster) elif name == "section": # Documentation data, skipped return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE) diff --git a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterClusters.jinja b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterClusters.jinja index 29b3b9c5f26788..c9802959d42d02 100644 --- a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterClusters.jinja +++ b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterClusters.jinja @@ -39,6 +39,71 @@ {%- endif -%} {%- endmacro -%} +{%- macro encode_tlv(encodable, tag, name, depth) %} + {%- if encodable.is_optional and encodable.is_nullable -%} + {{name}}?.let { + {{encode_tlv(encodable.without_optional().without_nullable(), tag, name, depth + 1)}} + } + {%- elif encodable.is_optional -%} + {{name}}?.let { + {{encode_tlv(encodable.without_optional(), tag, name, depth + 1)}} + } + {%- elif encodable.is_nullable -%} + {{name}}?.let { + {{encode_tlv(encodable.without_nullable(), tag, name, depth + 1)}} + } + {%- elif encodable.is_list -%} + tlvWriter.startArray({{tag}}) + for (item in {{name}}.iterator()) { + {{encode_tlv(encodable.without_list(), "AnonymousTag", "item", depth + 1)}} + } + tlvWriter.endArray() + {%- elif encodable.is_struct -%} + {{name}}.toTlv({{tag}}, tlvWriter) + {%- else -%} + tlvWriter.put({{tag}}, {{name}}) + {%- endif -%} +{%- endmacro -%} + +{%- macro decode_tlv(source, encodable, tag, depth) %} + {%- if encodable.is_nullable -%} + if (!tlvReader.isNull()) { + {{decode_tlv(source, encodable.without_nullable(), tag, depth + 1)}} + } else { + tlvReader.getNull({{tag}}) + null + } + {%- elif encodable.is_optional -%} + if (tlvReader.isNextTag({{tag}})) { + {{decode_tlv(source, encodable.without_optional(), tag, depth + 1)}} + } else { + null + } + {%- elif encodable.is_list -%} + {%- set encodablewithoutlist = encodable.without_list() -%} + buildList<{{encode_value(source, encodablewithoutlist, depth + 1)}}> { + tlvReader.enterArray({{tag}}) + while(!tlvReader.isEndOfContainer()) { + add({{decode_tlv(source, encodablewithoutlist, "AnonymousTag", depth + 1)}}) + } + tlvReader.exitContainer() + } + {%- elif encodable.is_struct -%} + {%- set struct = encodable.get_underlying_struct() -%} + {{source.name}}Cluster{{struct.name}}.fromTlv({{tag}}, tlvReader) + {%- else -%} + tlvReader.get{{encodable.kotlin_type}}({{tag}}) + {%- endif -%} +{%- endmacro -%} + +{%- macro contextSpecificTag(field) -%} + ContextSpecificTag(TAG_{{field.name | constcase}}) +{%- endmacro -%} + +{%- macro contextSpecificTag1(tag_value) -%} + ContextSpecificTag({{tag_value}}) +{%- endmacro -%} + /* * * Copyright (c) 2023 Project CHIP Authors @@ -56,10 +121,33 @@ * limitations under the License. */ -package matter.devicecontroller.cluster.clusters +package matter.controller.cluster.clusters +import java.util.logging.Level +import java.util.logging.Logger +import java.time.Duration import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* +import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse +import matter.controller.SubscribeRequest +import matter.controller.SubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException +import matter.tlv.TlvReader +import matter.tlv.TlvWriter {% set typeLookup = idl | createLookupContext(cluster) %} class {{cluster.name}}Cluster(private val controller: MatterController, private val endpointId: UShort) { @@ -118,64 +206,214 @@ class {{cluster.name}}Cluster(private val controller: MatterController, private : {{callbackName}} { {%- else %} { {%- endif %} - val commandId = {{command.code}}L -{% if command.is_timed_invoke %} - // Implementation needs to be added here -{%- else %} - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } -{%- endif %} + val commandId: UInt = {{command.code}}u +{% if command.is_timed_invoke -%} + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) +{%- else -%} + val timeoutMs: Duration = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO +{%- endif %} + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + {%- if command.input_param -%} + {% for field in (cluster.structs | named(command.input_param)).fields %} + {%- set encodable = field | asEncodable(typeLookup) %} + + val TAG_{{field.name | constcase}}_REQ: Int = {{field.code}} + {{encode_tlv(encodable, "ContextSpecificTag(TAG_" + field.name | constcase + "_REQ)", field.name | lowfirst_except_acronym, 0)}} + {%- endfor -%} + {%- endif %} + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + {%- if command | hasResponse %} + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + {%- set struct = cluster.structs | named(command.output_param) -%} + {%- for field in struct.fields %} + val TAG_{{field.name | constcase}}: Int = {{field.code}} + {% set encodable = field | asEncodable(typeLookup) -%} + {%- if encodable.is_optional or encodable.is_nullable-%} + var {{field.name | lowfirst_except_acronym}}_decoded: {{encode_value(cluster, field | asEncodable(typeLookup), 0)}} = null + {%- else -%} + var {{field.name | lowfirst_except_acronym}}_decoded: {{encode_value(cluster, field | asEncodable(typeLookup), 0)}}? = null + {%- endif %} + {% endfor %} + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + {% for field in struct.fields %} + if (tag == ContextSpecificTag(TAG_{{field.name | constcase}})) { + {%- set encodable = field | asEncodable(typeLookup) -%} + {%- if encodable.is_optional or encodable.is_nullable -%} + {{field.name | lowfirst_except_acronym}}_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + {{decode_tlv(cluster, encodable, "tag", 0)}} + } + {%- else -%} + {{field.name | lowfirst_except_acronym}}_decoded = {{decode_tlv(cluster, encodable, "tag", 0)}} + {%- endif -%} + } + {% endfor %} + + else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + {% for field in struct.fields %} + {% set encodable = field | asEncodable(typeLookup) -%} + {% if not encodable.is_optional and not encodable.is_nullable %} + if ({{field.name | lowfirst_except_acronym}}_decoded == null) { + throw IllegalStateException("{{field.name | lowfirst_except_acronym}} not found in TLV") + } + {%- endif %} + {% endfor %} + + tlvReader.exitContainer() + + return {{callbackName}}( + {%- for field in (cluster.structs | named(command.output_param)).fields %} + {{field.name | lowfirst_except_acronym}}_decoded{% if not loop.last %},{% endif %} + {%- endfor %} + ) + {%- endif %} } {% endfor -%} {% for attribute in cluster.attributes | sort(attribute='code') %} {%- set interfaceName = attribute | javaAttributeCallbackName(typeLookup) %} +{%- set attribute_id = "ATTRIBUTE_ID_" + attribute.definition.name | upper %} +{%- set encodable = attribute.definition | asEncodable(typeLookup) %} +{%- if attribute.definition is is_field_global_name(typeLookup) and encodable.is_optional -%} + suspend fun read{{ attribute.definition.name | upfirst }}Attribute(): {{interfaceName}}? { +{%- else -%} suspend fun read{{ attribute.definition.name | upfirst }}Attribute(): {{interfaceName}} { - // Implementation needs to be added here - } -{% if attribute | isFabricScopedList(typeLookup) %} - suspend fun read{{ attribute.definition.name | upfirst }}AttributeWithFabricFilter( - isFabricFiltered: Boolean - ): {{interfaceName}} { - // Implementation needs to be added here - } +{%- endif -%} + val ATTRIBUTE_ID: UInt = {{attribute.definition.code}}u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "{{ attribute.definition.name | capitalize }} attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: {{encode_value(cluster, encodable, 0)}} = {{decode_tlv(cluster, attribute.definition | asEncodable(typeLookup), "AnonymousTag", 0)}} -{% endif -%} -{%- if attribute.is_writable %} +{% if attribute.definition is is_field_global_name(typeLookup) %} + return decodedValue +{%- else %} + return {{interfaceName}}(decodedValue) +{%- endif %} + } +{% if attribute.is_writable %} {%- set encodable = attribute.definition | asEncodable(typeLookup) -%} -{%- set encodable2 = attribute.definition | asEncodable(typeLookup) %} +{%- set attribute_id = "ATTRIBUTE_ID_" + attribute.definition.name | upper %} suspend fun write{{ attribute.definition.name | upfirst }}Attribute( - value: {{ encode_value_without_optional_nullable(cluster, encodable2, 0) }}, + value: {{ encode_value_without_optional_nullable(cluster, encodable, 0) }}, {%- if attribute.requires_timed_write -%} timedWriteTimeoutMs: Int {%- else %} timedWriteTimeoutMs: Int? = null -{%- endif %} +{%- endif %} ) { -{%- if attribute.requires_timed_write %} - // Implementation needs to be added here -{%- else %} - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } + val ATTRIBUTE_ID: UInt = {{attribute.definition.code}}u +{% if attribute.requires_timed_write -%} + val timeoutMs: Duration = Duration.ofMillis(timedWriteTimeoutMs.toLong()) +{%- else -%} + val timeoutMs: Duration = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO {%- endif %} + + val tlvWriter = TlvWriter() + {%- set encodable = attribute.definition | asEncodable(typeLookup) %} + {%- if encodable.is_optional -%} + {%- set encodable = encodable.without_optional() %} + {%- endif %} + {%- if encodable.is_nullable -%} + {%- set encodable = encodable.without_nullable() %} + {%- endif %} + {%- set tag = contextSpecificTag(attribute) %} + {{encode_tlv(encodable, "AnonymousTag", "value", 0)}} + + val writeRequests: WriteRequests = + WriteRequests( + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } } {% endif %} -{%- if attribute.is_subscribable %} - suspend fun subscribe{{ attribute.definition.name | upfirst }}Attribute( - minInterval: Int, - maxInterval: Int - ): {{interfaceName}} { - // Implementation needs to be added here - } -{% endif -%} {%- endfor %} companion object { + private val logger = Logger.getLogger({{cluster.name}}Cluster::class.java.name) const val CLUSTER_ID: UInt = {{cluster.code}}u } } diff --git a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterEventStructs.jinja b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterEventStructs.jinja index e5b40bb8910301..7af63e3de67009 100644 --- a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterEventStructs.jinja +++ b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterEventStructs.jinja @@ -7,7 +7,7 @@ List<{{encode_value(source, encodable.without_list(), depth + 1)}}> {%- elif encodable.is_struct -%} {%- set struct = encodable.get_underlying_struct() -%} - matter.devicecontroller.cluster.structs.{{source.name}}Cluster{{struct.name}} + matter.controller.cluster.structs.{{source.name}}Cluster{{struct.name}} {%- else -%} {{encodable.kotlin_type}} {%- endif -%} @@ -63,7 +63,7 @@ } {%- elif encodable.is_struct -%} {%- set struct = encodable.get_underlying_struct() -%} - matter.devicecontroller.cluster.structs.{{source.name}}Cluster{{struct.name}}.fromTlv({{tag}}, tlvReader) + matter.controller.cluster.structs.{{source.name}}Cluster{{struct.name}}.fromTlv({{tag}}, tlvReader) {%- else -%} tlvReader.get{{encodable.kotlin_type}}({{tag}}) {%- endif -%} @@ -89,10 +89,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterFiles_gni.jinja b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterFiles_gni.jinja index 9094155de0d237..d174b402d2fd0c 100644 --- a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterFiles_gni.jinja +++ b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterFiles_gni.jinja @@ -6,7 +6,7 @@ matter_structs_sources = [ {%- set typeLookup = idl | createLookupContext(cluster) %} {%- for struct in cluster.structs | sort(attribute='name') %} {%- if not struct.tag %} - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/{{cluster.name}}Cluster{{struct.name}}.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/{{cluster.name}}Cluster{{struct.name}}.kt", {%- endif %} {%- endfor %} {%- endfor %} @@ -17,7 +17,7 @@ matter_eventstructs_sources = [ {%- set typeLookup = idl | createLookupContext(cluster) %} {%- for event in cluster.events | sort(attribute='name') %} {%- if event.fields %} - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/{{cluster.name}}Cluster{{event.name}}Event.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/{{cluster.name}}Cluster{{event.name}}Event.kt", {%- endif %} {%- endfor %} {%- endfor %} @@ -26,6 +26,6 @@ matter_eventstructs_sources = [ matter_clusters_sources = [ {%- for cluster in clientClusters | sort(attribute='name') %} {%- set typeLookup = idl | createLookupContext(cluster) %} - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/{{cluster.name}}Cluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/{{cluster.name}}Cluster.kt", {%- endfor %} ] \ No newline at end of file diff --git a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterStructs.jinja b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterStructs.jinja index 8a8769c0ceb95b..be0e0b9666af2d 100644 --- a/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterStructs.jinja +++ b/scripts/py_matter_idl/matter_idl/generators/kotlin/MatterStructs.jinja @@ -89,10 +89,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py b/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py index b671532df6682e..680c865e5d73e2 100644 --- a/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py @@ -65,9 +65,9 @@ def _UnderlyingType(field: Field, context: TypeLookupContext) -> Optional[str]: if isinstance(actual, BasicString): if actual.is_binary: - return 'OctetString' + return 'ByteArray' else: - return 'CharString' + return 'String' elif isinstance(actual, BasicInteger): if actual.is_signed: return "Int{}s".format(actual.power_of_two_bits) @@ -350,6 +350,11 @@ def __init__(self, context: TypeLookupContext, data_type: DataType, attrs: Set[E self.data_type = data_type self.attrs = attrs + @property + def is_basic_type(self): + """Returns True if this type is a basic type in Kotlin""" + return self.kotlin_type != "Any" + @property def is_nullable(self): return EncodableValueAttr.NULLABLE in self.attrs @@ -452,15 +457,23 @@ def kotlin_type(self): else: return "String" elif isinstance(t, IdlEnumType): - if t.base_type.byte_count >= 3: - return "ULong" - else: + if t.base_type.byte_count <= 1: + return "UByte" + elif t.base_type.byte_count <= 2: + return "UShort" + elif t.base_type.byte_count <= 4: return "UInt" - elif isinstance(t, IdlBitmapType): - if t.base_type.byte_count >= 3: - return "ULong" else: + return "ULong" + elif isinstance(t, IdlBitmapType): + if t.base_type.byte_count <= 1: + return "UByte" + elif t.base_type.byte_count <= 2: + return "UShort" + elif t.base_type.byte_count <= 4: return "UInt" + else: + return "ULong" else: return "Any" @@ -529,7 +542,7 @@ def boxed_java_signature(self): else: return "Ljava/lang/Integer;" else: - return "Lchip/devicecontroller/ChipStructs${}Cluster{};".format(self.context.cluster.name, self.data_type.name) + return "Lchip/controller/ChipStructs${}Cluster{};".format(self.context.cluster.name, self.data_type.name) def GlobalEncodableValueFrom(typeName: str, context: TypeLookupContext) -> EncodableValue: @@ -656,7 +669,7 @@ def internal_render_all(self): self.internal_render_one_output( template_path="MatterFiles_gni.jinja", - output_file_name="java/matter/devicecontroller/cluster/files.gni", + output_file_name="java/matter/controller/cluster/files.gni", vars={ 'idl': self.idl, 'clientClusters': clientClusters, @@ -665,7 +678,7 @@ def internal_render_all(self): # Generate a `.kt` file for each cluster. for cluster in clientClusters: - output_name = f"java/matter/devicecontroller/cluster/clusters/{cluster.name}Cluster.kt" + output_name = f"java/matter/controller/cluster/clusters/{cluster.name}Cluster.kt" self.internal_render_one_output( template_path="MatterClusters.jinja", output_file_name=output_name, @@ -682,7 +695,7 @@ def internal_render_all(self): if struct.tag: continue - output_name = "java/matter/devicecontroller/cluster/structs/{cluster_name}Cluster{struct_name}.kt" + output_name = "java/matter/controller/cluster/structs/{cluster_name}Cluster{struct_name}.kt" self.internal_render_one_output( template_path="MatterStructs.jinja", output_file_name=output_name.format( @@ -699,7 +712,7 @@ def internal_render_all(self): if not event.fields: continue - output_name = "java/matter/devicecontroller/cluster/eventstructs/{cluster_name}Cluster{event_name}Event.kt" + output_name = "java/matter/controller/cluster/eventstructs/{cluster_name}Cluster{event_name}Event.kt" self.internal_render_one_output( template_path="MatterEventStructs.jinja", output_file_name=output_name.format( diff --git a/scripts/py_matter_idl/matter_idl/test_data_model_xml.py b/scripts/py_matter_idl/matter_idl/test_data_model_xml.py index 06418f894ffcd6..647a275ea8d547 100755 --- a/scripts/py_matter_idl/matter_idl/test_data_model_xml.py +++ b/scripts/py_matter_idl/matter_idl/test_data_model_xml.py @@ -204,6 +204,8 @@ def testClusterDerivation(self): expected_idl = IdlTextToIdl(''' client cluster DishwasherMode = 89 { + revision 2; + bitmap Feature: bitmap32 { kOnOff = 0x1; } diff --git a/scripts/setup/constraints.txt b/scripts/setup/constraints.txt index b0e9aed4ae60e7..ad80df20c4ab24 100644 --- a/scripts/setup/constraints.txt +++ b/scripts/setup/constraints.txt @@ -163,7 +163,7 @@ portpicker==1.5.2 # via # -r requirements.all.txt # mobly -prompt-toolkit==3.0.38 +prompt-toolkit==3.0.43 # via ipython protobuf==4.24.4 # via diff --git a/scripts/setup/requirements.ti.txt b/scripts/setup/requirements.ti.txt index b832ec6cf68b69..07f5e30471f1c1 100644 --- a/scripts/setup/requirements.ti.txt +++ b/scripts/setup/requirements.ti.txt @@ -1,2 +1,5 @@ +cbor>=1.0.0 +click +cryptography>=2.6 ecdsa>=0.17.0 intelhex diff --git a/scripts/tools/zap/tests/inputs/all-clusters-app.zap b/scripts/tools/zap/tests/inputs/all-clusters-app.zap index c62d16a6db7703..65cf99d5b0f510 100644 --- a/scripts/tools/zap/tests/inputs/all-clusters-app.zap +++ b/scripts/tools/zap/tests/inputs/all-clusters-app.zap @@ -16797,5 +16797,6 @@ "endpointId": 65534, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/scripts/tools/zap/tests/inputs/lighting-app.zap b/scripts/tools/zap/tests/inputs/lighting-app.zap index 0a3f56f8d981bc..58db6ff25f5d15 100644 --- a/scripts/tools/zap/tests/inputs/lighting-app.zap +++ b/scripts/tools/zap/tests/inputs/lighting-app.zap @@ -5742,5 +5742,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp new file mode 100644 index 00000000000000..fcc75ef319d60c --- /dev/null +++ b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp @@ -0,0 +1,208 @@ +/* + * + * 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 "electrical-energy-measurement-server.h" + +#include + +#include +#include +#include +#include + +using chip::Protocols::InteractionModel::Status; + +namespace { + +using namespace chip; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement::Attributes; +using namespace chip::app::Clusters::ElectricalEnergyMeasurement::Structs; + +struct MeasurementData +{ + MeasurementAccuracyStruct::Type measurementAccuracy; + Optional cumulativeImported; + Optional cumulativeExported; + Optional periodicImported; + Optional periodicExported; +}; + +MeasurementData + gMeasurements[EMBER_AF_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; + +MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId) +{ + auto index = emberAfGetClusterServerEndpointIndex(endpointId, app::Clusters::ElectricalEnergyMeasurement::Id, + EMBER_AF_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT); + + if (index == kEmberInvalidEndpointIndex) + { + return nullptr; + } + + if (index >= EMBER_AF_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT) + { + ChipLogError(NotSpecified, "Internal error: invalid/unexpected energy measurement index."); + return nullptr; + } + return &gMeasurements[index]; +} + +class ElectricalEnergyMeasurementAttrAccess : public app::AttributeAccessInterface +{ +public: + ElectricalEnergyMeasurementAttrAccess() : + app::AttributeAccessInterface(Optional::Missing(), app::Clusters::ElectricalEnergyMeasurement::Id) + {} + + CHIP_ERROR Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) override; +}; + +CHIP_ERROR ElectricalEnergyMeasurementAttrAccess::Read(const app::ConcreteReadAttributePath & aPath, + app::AttributeValueEncoder & aEncoder) +{ + VerifyOrDie(aPath.mClusterId == app::Clusters::ElectricalEnergyMeasurement::Id); + + MeasurementData * data = MeasurementDataForEndpoint(aPath.mEndpointId); + + switch (aPath.mAttributeId) + { + case Accuracy::Id: + if (data == nullptr) + { + return CHIP_ERROR_NOT_FOUND; + } + return aEncoder.Encode(data->measurementAccuracy); + case CumulativeEnergyImported::Id: + if ((data == nullptr) || !data->cumulativeImported.HasValue()) + { + return aEncoder.EncodeNull(); + } + return aEncoder.Encode(data->cumulativeImported.Value()); + case CumulativeEnergyExported::Id: + if ((data == nullptr) || !data->cumulativeExported.HasValue()) + { + return aEncoder.EncodeNull(); + } + return aEncoder.Encode(data->cumulativeExported.Value()); + case PeriodicEnergyImported::Id: + if ((data == nullptr) || !data->periodicImported.HasValue()) + { + return aEncoder.EncodeNull(); + } + return aEncoder.Encode(data->periodicImported.Value()); + case PeriodicEnergyExported::Id: + if ((data == nullptr) || !data->periodicExported.HasValue()) + { + return aEncoder.EncodeNull(); + } + return aEncoder.Encode(data->periodicExported.Value()); + } + + return CHIP_NO_ERROR; +} + +ElectricalEnergyMeasurementAttrAccess gAttrAccess; + +} // namespace + +namespace chip { +namespace app { +namespace Clusters { +namespace ElectricalEnergyMeasurement { + +CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const MeasurementAccuracyStruct::Type & accuracy) +{ + + MeasurementData * data = MeasurementDataForEndpoint(endpointId); + VerifyOrReturnError(data != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + + data->measurementAccuracy = accuracy; + + MatterReportingAttributeChangeCallback(endpointId, ElectricalEnergyMeasurement::Id, Accuracy::Id); + + return CHIP_NO_ERROR; +} + +bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional & energyImported, + const Optional & energyExported) +{ + MeasurementData * data = MeasurementDataForEndpoint(endpointId); + if (data != nullptr) + { + data->cumulativeImported = energyImported; + data->cumulativeExported = energyExported; + } + + Events::CumulativeEnergyMeasured::Type event; + + event.energyImported = energyImported; + event.energyExported = energyExported; + + EventNumber eventNumber; + CHIP_ERROR error = app::LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "[NotifyCumulativeEnergyMeasured] Unable to send event: %" CHIP_ERROR_FORMAT " [endpointId=%d]", + error.Format(), endpointId); + return false; + } + ChipLogProgress(Zcl, "[NotifyCumulativeEnergyMeasured] Sent event [endpointId=%d,eventNumber=%lu]", endpointId, + static_cast(eventNumber)); + return true; +} + +bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional & energyImported, + const Optional & energyExported) +{ + MeasurementData * data = MeasurementDataForEndpoint(endpointId); + if (data != nullptr) + { + data->periodicImported = energyImported; + data->periodicExported = energyExported; + } + + Events::PeriodicEnergyMeasured::Type event; + + event.energyImported = energyImported; + event.energyExported = energyExported; + + EventNumber eventNumber; + CHIP_ERROR error = app::LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "[NotifyPeriodicEnergyMeasured] Unable to send event: %" CHIP_ERROR_FORMAT " [endpointId=%d]", + error.Format(), endpointId); + return false; + } + ChipLogProgress(Zcl, "[NotifyPeriodicEnergyMeasured] Sent event [endpointId=%d,eventNumber=%lu]", endpointId, + static_cast(eventNumber)); + return true; +} + +} // namespace ElectricalEnergyMeasurement +} // namespace Clusters +} // namespace app +} // namespace chip + +void MatterElectricalEnergyMeasurementPluginServerInitCallback() +{ + registerAttributeAccessOverride(&gAttrAccess); +} diff --git a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.h b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.h new file mode 100644 index 00000000000000..8647b9bde0b750 --- /dev/null +++ b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.h @@ -0,0 +1,40 @@ +/* + * + * 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 + +namespace chip { +namespace app { +namespace Clusters { +namespace ElectricalEnergyMeasurement { + +bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional & energyImported, + const Optional & energyExported); + +bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional & energyImported, + const Optional & energyExported); + +CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const Structs::MeasurementAccuracyStruct::Type & accuracy); + +} // namespace ElectricalEnergyMeasurement +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/sample-mei-server/sample-mei-server.cpp b/src/app/clusters/sample-mei-server/sample-mei-server.cpp index 94b83419f59a87..22a8f48bdf8a00 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.cpp +++ b/src/app/clusters/sample-mei-server/sample-mei-server.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,8 @@ SampleMeiContent::SampleMeiContent() : SampleMeiContent(kInvalidEndpointId) {} SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) { - endpoint = aEndpoint; + endpoint = aEndpoint; + pingCount = 10000; // Attribute default values flipflop = false; @@ -70,6 +72,7 @@ SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) { auto endpoint = ctxt.mRequestPath.mEndpointId; + auto fabricIndex = ctxt.mCommandHandler.GetAccessingFabricIndex(); auto endpointIndex = EndpointIndex(endpoint); if (endpointIndex == std::numeric_limits::max()) { @@ -80,10 +83,19 @@ void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) switch (ctxt.mRequestPath.mCommandId) { case Commands::Ping::Id: - HandleCommand(ctxt, [endpoint](HandlerContext & ctx, const auto & req) { - ChipLogProgress(Zcl, "Ping Command on Ep %d", endpoint); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); - }); + HandleCommand( + ctxt, [this, endpoint, fabricIndex, endpointIndex, ctxt](HandlerContext & ctx, const auto & req) { + ChipLogProgress(Zcl, "Ping Command on Ep %d", endpoint); + Events::PingCountEvent::Type event{ .count = content[endpointIndex].pingCount++, .fabricIndex = fabricIndex }; + chip::EventNumber placeholderEventNumber; + CHIP_ERROR err = LogEvent(event, endpoint, placeholderEventNumber); + if (CHIP_NO_ERROR != err) + { + ChipLogError(Zcl, "Failed to record event on endpoint %d: %" CHIP_ERROR_FORMAT, static_cast(endpoint), + err.Format()); + } + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); + }); return; case Commands::AddArguments::Id: HandleCommand(ctxt, [endpoint](HandlerContext & ctx, const auto & req) { diff --git a/src/app/clusters/sample-mei-server/sample-mei-server.h b/src/app/clusters/sample-mei-server/sample-mei-server.h index 3f4463215e4acc..9f5307dba6d753 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.h +++ b/src/app/clusters/sample-mei-server/sample-mei-server.h @@ -32,6 +32,7 @@ class SampleMeiContent { public: EndpointId endpoint; + uint32_t pingCount; // Attribute List bool flipflop; /* Attributes::FlipFlop::Id */ diff --git a/src/app/icd/client/DefaultICDClientStorage.h b/src/app/icd/client/DefaultICDClientStorage.h index 83729dced069b1..be1c8a2f4056ae 100644 --- a/src/app/icd/client/DefaultICDClientStorage.h +++ b/src/app/icd/client/DefaultICDClientStorage.h @@ -15,6 +15,10 @@ * limitations under the License. */ +// Do not use the DefaultICDClientStorage class in settings where fabric indices are not stable. +// This class relies on the stability of fabric indices for efficient storage and retrieval of ICD client information. +// If fabric indices are not stable, the functionality of this class will be compromised and can lead to unexpected behavior. + #pragma once #include "ICDClientStorage.h" @@ -52,6 +56,17 @@ class DefaultICDClientStorage : public ICDClientStorage ICDClientInfoIterator * IterateICDClientInfo() override; + /** + * When decrypting check-in messages, the system needs to iterate through all keys + * from all ICD clientInfos. In DefaultICDClientStorage, ICDClientInfos for the same fabric are stored in + * storage using the fabricIndex as the key. To retrieve all relevant ICDClientInfos + * from storage, the system needs to know all fabricIndices in advance. The + * `UpdateFabricList` function provides a way to inject newly created fabricIndices + * into a dedicated table. It is recommended to call this function whenever a controller is created + * with a new fabric index. + * + * @param[in] fabricIndex The newly created fabric index. + */ CHIP_ERROR UpdateFabricList(FabricIndex fabricIndex); CHIP_ERROR SetKey(ICDClientInfo & clientInfo, const ByteSpan keyData) override; diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index f9aac9ee4491f5..4ea9ce1285409b 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -57,9 +57,11 @@ #define DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName) EmberAfCluster clusterListName[] = { -#define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands) \ +// The role argument should be used to determine whether cluster works as a server or a client. +// It can be assigned with the ZAP_CLUSTER_MASK(SERVER) or ZAP_CLUSTER_MASK(CLUSTER) values. +#define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands) \ { \ - clusterId, clusterAttrs, ArraySize(clusterAttrs), 0, ZAP_CLUSTER_MASK(SERVER), NULL, incomingCommands, outgoingCommands \ + clusterId, clusterAttrs, ArraySize(clusterAttrs), 0, role, NULL, incomingCommands, outgoingCommands \ } #define DECLARE_DYNAMIC_CLUSTER_LIST_END } diff --git a/src/app/zap-templates/zcl/data-model/all.xml b/src/app/zap-templates/zcl/data-model/all.xml index cef3f6053ccf89..3556c0309206e7 100644 --- a/src/app/zap-templates/zcl/data-model/all.xml +++ b/src/app/zap-templates/zcl/data-model/all.xml @@ -31,6 +31,7 @@ + diff --git a/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml new file mode 100644 index 00000000000000..6271b56d235a61 --- /dev/null +++ b/src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Electrical Energy Measurement + Measurement & Sensing + This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. + 0x0091 + ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER + true + true + + + Accuracy + CumulativeEnergyImported + CumulativeEnergyExported + PeriodicEnergyImported + PeriodicEnergyExported + + + This event SHALL be generated when the server takes a snapshot of the cumulative energy imported by the server, exported from the server of both. + + + + + + This event SHALL be generated when the server reaches the end of a reporting period for imported energy, exported energy, or both. + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml index d51b1ce8fad5a5..bb232270f62430 100644 --- a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +++ b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml @@ -1897,6 +1897,7 @@ limitations under the License. + diff --git a/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml index ca5768f156476e..9b812b85c535d3 100644 --- a/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml @@ -54,6 +54,11 @@ limitations under the License. Simple command without any parameters and without a response. + + + Example events generated by Ping command + + 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 c1c33570d71a5c..1bab6d709d05df 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -45,6 +45,7 @@ "microwave-oven-mode-cluster.xml", "microwave-oven-control-cluster.xml", "door-lock-cluster.xml", + "electrical-energy-measurement-cluster.xml", "electrical-measurement-cluster.xml", "energy-evse-cluster.xml", "ethernet-network-diagnostics-cluster.xml", @@ -545,7 +546,14 @@ "LevelValue", "FeatureMap" ], - "Air Quality": ["AirQuality", "FeatureMap"] + "Air Quality": ["AirQuality", "FeatureMap"], + "Electrical Energy Measurement": [ + "Accuracy", + "CumulativeEnergyImported", + "CumulativeEnergyExported", + "PeriodicEnergyImported", + "PeriodicEnergyExported" + ] }, "defaultReportingPolicy": "mandatory", "ZCLDataTypes": ["ARRAY", "BITMAP", "ENUM", "NUMBER", "STRING", "STRUCT"], diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index e000e0fc738163..257222de56ad40 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -42,6 +42,7 @@ "dishwasher-mode-cluster.xml", "microwave-oven-mode-cluster.xml", "door-lock-cluster.xml", + "electrical-energy-measurement-cluster.xml", "drlc-cluster.xml", "electrical-measurement-cluster.xml", "energy-evse-cluster.xml", @@ -543,7 +544,14 @@ "LevelValue", "FeatureMap" ], - "Air Quality": ["AirQuality", "FeatureMap"] + "Air Quality": ["AirQuality", "FeatureMap"], + "Electrical Energy Measurement": [ + "Accuracy", + "CumulativeEnergyImported", + "CumulativeEnergyExported", + "PeriodicEnergyImported", + "PeriodicEnergyExported" + ] }, "defaultReportingPolicy": "mandatory", "ZCLDataTypes": ["ARRAY", "BITMAP", "ENUM", "NUMBER", "STRING", "STRUCT"], diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json index 31c8515cd98666..cdd92f9698b1e8 100644 --- a/src/app/zap_cluster_list.json +++ b/src/app/zap_cluster_list.json @@ -35,6 +35,7 @@ "DISHWASHER_MODE_CLUSTER": [], "MICROWAVE_OVEN_MODE_CLUSTER": [], "DOOR_LOCK_CLUSTER": [], + "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER": [], "ELECTRICAL_MEASUREMENT_CLUSTER": [], "ENERGY_EVSE_CLUSTER": [], "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER": [], @@ -170,6 +171,9 @@ "DISHWASHER_MODE_CLUSTER": ["mode-base-server"], "MICROWAVE_OVEN_MODE_CLUSTER": ["mode-base-server"], "DOOR_LOCK_CLUSTER": ["door-lock-server"], + "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER": [ + "electrical-energy-measurement-server" + ], "ELECTRICAL_MEASUREMENT_CLUSTER": [], "ENERGY_EVSE_CLUSTER": ["energy-evse-server"], "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER": [ diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 3602cad6d8899a..5ee0a9704a4462 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4107,6 +4107,85 @@ provisional cluster ValveConfigurationAndControl = 129 { command SetLevel(SetLevelRequest): DefaultSuccess = 2; } +/** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */ +provisional cluster ElectricalEnergyMeasurement = 145 { + revision 1; + + enum MeasurementTypeEnum : enum16 { + kUnspecified = 0; + kVoltage = 1; + kActiveCurrent = 2; + kReactiveCurrent = 3; + kApparentCurrent = 4; + kActivePower = 5; + kReactivePower = 6; + kApparentPower = 7; + kRMSVoltage = 8; + kRMSCurrent = 9; + kRMSPower = 10; + kFrequency = 11; + kPowerFactor = 12; + kNeutralCurrent = 13; + kElectricalEnergy = 14; + } + + bitmap Feature : bitmap32 { + kImportedEnergy = 0x1; + kExportedEnergy = 0x2; + kCumulativeEnergy = 0x4; + kPeriodicEnergy = 0x8; + } + + struct MeasurementAccuracyRangeStruct { + int64s rangeMin = 0; + int64s rangeMax = 1; + optional percent100ths percentMax = 2; + optional percent100ths percentMin = 3; + optional percent100ths percentTypical = 4; + optional int64u fixedMax = 5; + optional int64u fixedMin = 6; + optional int64u fixedTypical = 7; + } + + struct MeasurementAccuracyStruct { + MeasurementTypeEnum measurementType = 0; + boolean measured = 1; + int64s minMeasuredValue = 2; + int64s maxMeasuredValue = 3; + MeasurementAccuracyRangeStruct accuracyRanges[] = 4; + } + + struct EnergyMeasurementStruct { + int64s energy = 0; + optional epoch_s startTimestamp = 1; + optional epoch_s endTimestamp = 2; + optional systime_ms startSystime = 3; + optional systime_ms endSystime = 4; + } + + info event CumulativeEnergyMeasured = 0 { + optional EnergyMeasurementStruct energyImported = 0; + optional EnergyMeasurementStruct energyExported = 1; + } + + info event PeriodicEnergyMeasured = 1 { + optional EnergyMeasurementStruct energyImported = 0; + optional EnergyMeasurementStruct energyExported = 1; + } + + readonly attribute MeasurementAccuracyStruct accuracy = 0; + readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyImported = 1; + readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2; + readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3; + readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4; + 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; +} + /** This cluster provides an interface to the functionality of Smart Energy Demand Response and Load Control. */ provisional cluster DemandResponseLoadControl = 150 { revision 4; @@ -8724,6 +8803,11 @@ internal cluster FaultInjection = 4294048774 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set + fabric_sensitive info event PingCountEvent = 0 { + int32u count = 1; + fabric_idx fabricIndex = 254; + } + attribute boolean flipFlop = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; diff --git a/src/controller/java/BUILD.gn b/src/controller/java/BUILD.gn index 31116c55a79d6c..588535bd823016 100644 --- a/src/controller/java/BUILD.gn +++ b/src/controller/java/BUILD.gn @@ -352,7 +352,7 @@ kotlin_library("chipcluster_test") { kotlin_library("kotlin_matter_controller") { import( - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni") + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/files.gni") output_name = "KotlinMatterController.jar" @@ -377,6 +377,7 @@ kotlin_library("kotlin_matter_controller") { sources += matter_structs_sources sources += matter_eventstructs_sources + sources += matter_clusters_sources if (matter_enable_java_compilation) { deps += [ diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 1eed51794fad6f..b571ac051e3f2b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -28311,6 +28311,343 @@ public void onSuccess(byte[] tlv) { } } + public static class ElectricalEnergyMeasurementCluster extends BaseChipCluster { + public static final long CLUSTER_ID = 145L; + + private static final long ACCURACY_ATTRIBUTE_ID = 0L; + private static final long CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID = 1L; + private static final long CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID = 2L; + private static final long PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID = 3L; + private static final long PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID = 4L; + private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L; + private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L; + private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L; + private static final long ATTRIBUTE_LIST_ATTRIBUTE_ID = 65531L; + private static final long FEATURE_MAP_ATTRIBUTE_ID = 65532L; + private static final long CLUSTER_REVISION_ATTRIBUTE_ID = 65533L; + + public ElectricalEnergyMeasurementCluster(long devicePtr, int endpointId) { + super(devicePtr, endpointId, CLUSTER_ID); + } + + @Override + @Deprecated + public long initWithDevice(long devicePtr, int endpointId) { + return 0L; + } + + public interface AccuracyAttributeCallback extends BaseAttributeCallback { + void onSuccess(ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value); + } + + public interface CumulativeEnergyImportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface CumulativeEnergyExportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface PeriodicEnergyImportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface PeriodicEnergyExportedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value); + } + + public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface AcceptedCommandListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface EventListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public interface AttributeListAttributeCallback extends BaseAttributeCallback { + void onSuccess(List value); + } + + public void readAccuracyAttribute( + AccuracyAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACCURACY_ATTRIBUTE_ID, true); + } + + public void subscribeAccuracyAttribute( + AccuracyAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACCURACY_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readCumulativeEnergyImportedAttribute( + CumulativeEnergyImportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + } + + public void subscribeCumulativeEnergyImportedAttribute( + CumulativeEnergyImportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readCumulativeEnergyExportedAttribute( + CumulativeEnergyExportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + } + + public void subscribeCumulativeEnergyExportedAttribute( + CumulativeEnergyExportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readPeriodicEnergyImportedAttribute( + PeriodicEnergyImportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + } + + public void subscribePeriodicEnergyImportedAttribute( + PeriodicEnergyImportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readPeriodicEnergyExportedAttribute( + PeriodicEnergyExportedAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + } + + public void subscribePeriodicEnergyExportedAttribute( + PeriodicEnergyExportedAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readEventListAttribute( + EventListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, EVENT_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeEventListAttribute( + EventListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, EVENT_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readAttributeListAttribute( + AttributeListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ATTRIBUTE_LIST_ATTRIBUTE_ID, true); + } + + public void subscribeAttributeListAttribute( + AttributeListAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ATTRIBUTE_LIST_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readFeatureMapAttribute( + LongAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, FEATURE_MAP_ATTRIBUTE_ID, true); + } + + public void subscribeFeatureMapAttribute( + LongAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, FEATURE_MAP_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readClusterRevisionAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, CLUSTER_REVISION_ATTRIBUTE_ID, true); + } + + public void subscribeClusterRevisionAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, CLUSTER_REVISION_ATTRIBUTE_ID, minInterval, maxInterval); + } + } + public static class DemandResponseLoadControlCluster extends BaseChipCluster { public static final long CLUSTER_ID = 150L; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java index 256d205a09e8df..81b0180a39df4f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -3060,6 +3060,128 @@ public String toString() { return output.toString(); } } +public static class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + public Optional energyImported; + public Optional energyExported; + private static final long ENERGY_IMPORTED_ID = 0L; + private static final long ENERGY_EXPORTED_ID = 1L; + + public ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + Optional energyImported, + Optional energyExported + ) { + this.energyImported = energyImported; + this.energyExported = energyExported; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(ENERGY_IMPORTED_ID, energyImported.map((nonOptionalenergyImported) -> nonOptionalenergyImported.encodeTlv()).orElse(new EmptyType()))); + values.add(new StructElement(ENERGY_EXPORTED_ID, energyExported.map((nonOptionalenergyExported) -> nonOptionalenergyExported.encodeTlv()).orElse(new EmptyType()))); + + return new StructType(values); + } + + public static ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Optional energyImported = Optional.empty(); + Optional energyExported = Optional.empty(); + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == ENERGY_IMPORTED_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Struct) { + StructType castingValue = element.value(StructType.class); + energyImported = Optional.of(ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.decodeTlv(castingValue)); + } + } else if (element.contextTagNum() == ENERGY_EXPORTED_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Struct) { + StructType castingValue = element.value(StructType.class); + energyExported = Optional.of(ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.decodeTlv(castingValue)); + } + } + } + return new ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n"); + output.append("\tenergyImported: "); + output.append(energyImported); + output.append("\n"); + output.append("\tenergyExported: "); + output.append(energyExported); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + public Optional energyImported; + public Optional energyExported; + private static final long ENERGY_IMPORTED_ID = 0L; + private static final long ENERGY_EXPORTED_ID = 1L; + + public ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + Optional energyImported, + Optional energyExported + ) { + this.energyImported = energyImported; + this.energyExported = energyExported; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(ENERGY_IMPORTED_ID, energyImported.map((nonOptionalenergyImported) -> nonOptionalenergyImported.encodeTlv()).orElse(new EmptyType()))); + values.add(new StructElement(ENERGY_EXPORTED_ID, energyExported.map((nonOptionalenergyExported) -> nonOptionalenergyExported.encodeTlv()).orElse(new EmptyType()))); + + return new StructType(values); + } + + public static ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Optional energyImported = Optional.empty(); + Optional energyExported = Optional.empty(); + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == ENERGY_IMPORTED_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Struct) { + StructType castingValue = element.value(StructType.class); + energyImported = Optional.of(ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.decodeTlv(castingValue)); + } + } else if (element.contextTagNum() == ENERGY_EXPORTED_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Struct) { + StructType castingValue = element.value(StructType.class); + energyExported = Optional.of(ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.decodeTlv(castingValue)); + } + } + } + return new ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n"); + output.append("\tenergyImported: "); + output.append(energyImported); + output.append("\n"); + output.append("\tenergyExported: "); + output.append(energyExported); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} public static class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { public byte[] eventID; public @Nullable Integer transitionIndex; @@ -4713,4 +4835,65 @@ public String toString() { return output.toString(); } } +public static class SampleMeiClusterPingCountEventEvent { + public Long count; + public Integer fabricIndex; + private static final long COUNT_ID = 1L; + private static final long FABRIC_INDEX_ID = 254L; + + public SampleMeiClusterPingCountEventEvent( + Long count, + Integer fabricIndex + ) { + this.count = count; + this.fabricIndex = fabricIndex; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(COUNT_ID, new UIntType(count))); + values.add(new StructElement(FABRIC_INDEX_ID, new UIntType(fabricIndex))); + + return new StructType(values); + } + + public static SampleMeiClusterPingCountEventEvent decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Long count = null; + Integer fabricIndex = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == COUNT_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + count = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == FABRIC_INDEX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fabricIndex = castingValue.value(Integer.class); + } + } + } + return new SampleMeiClusterPingCountEventEvent( + count, + fabricIndex + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("SampleMeiClusterPingCountEventEvent {\n"); + output.append("\tcount: "); + output.append(count); + output.append("\n"); + output.append("\tfabricIndex: "); + output.append(fabricIndex); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java index ba1b077bbf57b2..0237b3fc989cd2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java @@ -5428,6 +5428,369 @@ public String toString() { return output.toString(); } } +public static class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + public Long rangeMin; + public Long rangeMax; + public Optional percentMax; + public Optional percentMin; + public Optional percentTypical; + public Optional fixedMax; + public Optional fixedMin; + public Optional fixedTypical; + private static final long RANGE_MIN_ID = 0L; + private static final long RANGE_MAX_ID = 1L; + private static final long PERCENT_MAX_ID = 2L; + private static final long PERCENT_MIN_ID = 3L; + private static final long PERCENT_TYPICAL_ID = 4L; + private static final long FIXED_MAX_ID = 5L; + private static final long FIXED_MIN_ID = 6L; + private static final long FIXED_TYPICAL_ID = 7L; + + public ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + Long rangeMin, + Long rangeMax, + Optional percentMax, + Optional percentMin, + Optional percentTypical, + Optional fixedMax, + Optional fixedMin, + Optional fixedTypical + ) { + this.rangeMin = rangeMin; + this.rangeMax = rangeMax; + this.percentMax = percentMax; + this.percentMin = percentMin; + this.percentTypical = percentTypical; + this.fixedMax = fixedMax; + this.fixedMin = fixedMin; + this.fixedTypical = fixedTypical; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(RANGE_MIN_ID, new IntType(rangeMin))); + values.add(new StructElement(RANGE_MAX_ID, new IntType(rangeMax))); + values.add(new StructElement(PERCENT_MAX_ID, percentMax.map((nonOptionalpercentMax) -> new UIntType(nonOptionalpercentMax)).orElse(new EmptyType()))); + values.add(new StructElement(PERCENT_MIN_ID, percentMin.map((nonOptionalpercentMin) -> new UIntType(nonOptionalpercentMin)).orElse(new EmptyType()))); + values.add(new StructElement(PERCENT_TYPICAL_ID, percentTypical.map((nonOptionalpercentTypical) -> new UIntType(nonOptionalpercentTypical)).orElse(new EmptyType()))); + values.add(new StructElement(FIXED_MAX_ID, fixedMax.map((nonOptionalfixedMax) -> new UIntType(nonOptionalfixedMax)).orElse(new EmptyType()))); + values.add(new StructElement(FIXED_MIN_ID, fixedMin.map((nonOptionalfixedMin) -> new UIntType(nonOptionalfixedMin)).orElse(new EmptyType()))); + values.add(new StructElement(FIXED_TYPICAL_ID, fixedTypical.map((nonOptionalfixedTypical) -> new UIntType(nonOptionalfixedTypical)).orElse(new EmptyType()))); + + return new StructType(values); + } + + public static ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Long rangeMin = null; + Long rangeMax = null; + Optional percentMax = Optional.empty(); + Optional percentMin = Optional.empty(); + Optional percentTypical = Optional.empty(); + Optional fixedMax = Optional.empty(); + Optional fixedMin = Optional.empty(); + Optional fixedTypical = Optional.empty(); + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == RANGE_MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + rangeMin = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == RANGE_MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + rangeMax = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == PERCENT_MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + percentMax = Optional.of(castingValue.value(Integer.class)); + } + } else if (element.contextTagNum() == PERCENT_MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + percentMin = Optional.of(castingValue.value(Integer.class)); + } + } else if (element.contextTagNum() == PERCENT_TYPICAL_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + percentTypical = Optional.of(castingValue.value(Integer.class)); + } + } else if (element.contextTagNum() == FIXED_MAX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fixedMax = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == FIXED_MIN_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fixedMin = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == FIXED_TYPICAL_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fixedTypical = Optional.of(castingValue.value(Long.class)); + } + } + } + return new ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct {\n"); + output.append("\trangeMin: "); + output.append(rangeMin); + output.append("\n"); + output.append("\trangeMax: "); + output.append(rangeMax); + output.append("\n"); + output.append("\tpercentMax: "); + output.append(percentMax); + output.append("\n"); + output.append("\tpercentMin: "); + output.append(percentMin); + output.append("\n"); + output.append("\tpercentTypical: "); + output.append(percentTypical); + output.append("\n"); + output.append("\tfixedMax: "); + output.append(fixedMax); + output.append("\n"); + output.append("\tfixedMin: "); + output.append(fixedMin); + output.append("\n"); + output.append("\tfixedTypical: "); + output.append(fixedTypical); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + public Integer measurementType; + public Boolean measured; + public Long minMeasuredValue; + public Long maxMeasuredValue; + public ArrayList accuracyRanges; + private static final long MEASUREMENT_TYPE_ID = 0L; + private static final long MEASURED_ID = 1L; + private static final long MIN_MEASURED_VALUE_ID = 2L; + private static final long MAX_MEASURED_VALUE_ID = 3L; + private static final long ACCURACY_RANGES_ID = 4L; + + public ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + Integer measurementType, + Boolean measured, + Long minMeasuredValue, + Long maxMeasuredValue, + ArrayList accuracyRanges + ) { + this.measurementType = measurementType; + this.measured = measured; + this.minMeasuredValue = minMeasuredValue; + this.maxMeasuredValue = maxMeasuredValue; + this.accuracyRanges = accuracyRanges; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(MEASUREMENT_TYPE_ID, new UIntType(measurementType))); + values.add(new StructElement(MEASURED_ID, new BooleanType(measured))); + values.add(new StructElement(MIN_MEASURED_VALUE_ID, new IntType(minMeasuredValue))); + values.add(new StructElement(MAX_MEASURED_VALUE_ID, new IntType(maxMeasuredValue))); + values.add(new StructElement(ACCURACY_RANGES_ID, ArrayType.generateArrayType(accuracyRanges, (elementaccuracyRanges) -> elementaccuracyRanges.encodeTlv()))); + + return new StructType(values); + } + + public static ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Integer measurementType = null; + Boolean measured = null; + Long minMeasuredValue = null; + Long maxMeasuredValue = null; + ArrayList accuracyRanges = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == MEASUREMENT_TYPE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + measurementType = castingValue.value(Integer.class); + } + } else if (element.contextTagNum() == MEASURED_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Boolean) { + BooleanType castingValue = element.value(BooleanType.class); + measured = castingValue.value(Boolean.class); + } + } else if (element.contextTagNum() == MIN_MEASURED_VALUE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + minMeasuredValue = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MAX_MEASURED_VALUE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + maxMeasuredValue = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == ACCURACY_RANGES_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Array) { + ArrayType castingValue = element.value(ArrayType.class); + accuracyRanges = castingValue.map((elementcastingValue) -> ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.decodeTlv(elementcastingValue)); + } + } + } + return new ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct {\n"); + output.append("\tmeasurementType: "); + output.append(measurementType); + output.append("\n"); + output.append("\tmeasured: "); + output.append(measured); + output.append("\n"); + output.append("\tminMeasuredValue: "); + output.append(minMeasuredValue); + output.append("\n"); + output.append("\tmaxMeasuredValue: "); + output.append(maxMeasuredValue); + output.append("\n"); + output.append("\taccuracyRanges: "); + output.append(accuracyRanges); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + public Long energy; + public Optional startTimestamp; + public Optional endTimestamp; + public Optional startSystime; + public Optional endSystime; + private static final long ENERGY_ID = 0L; + private static final long START_TIMESTAMP_ID = 1L; + private static final long END_TIMESTAMP_ID = 2L; + private static final long START_SYSTIME_ID = 3L; + private static final long END_SYSTIME_ID = 4L; + + public ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + Long energy, + Optional startTimestamp, + Optional endTimestamp, + Optional startSystime, + Optional endSystime + ) { + this.energy = energy; + this.startTimestamp = startTimestamp; + this.endTimestamp = endTimestamp; + this.startSystime = startSystime; + this.endSystime = endSystime; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(ENERGY_ID, new IntType(energy))); + values.add(new StructElement(START_TIMESTAMP_ID, startTimestamp.map((nonOptionalstartTimestamp) -> new UIntType(nonOptionalstartTimestamp)).orElse(new EmptyType()))); + values.add(new StructElement(END_TIMESTAMP_ID, endTimestamp.map((nonOptionalendTimestamp) -> new UIntType(nonOptionalendTimestamp)).orElse(new EmptyType()))); + values.add(new StructElement(START_SYSTIME_ID, startSystime.map((nonOptionalstartSystime) -> new UIntType(nonOptionalstartSystime)).orElse(new EmptyType()))); + values.add(new StructElement(END_SYSTIME_ID, endSystime.map((nonOptionalendSystime) -> new UIntType(nonOptionalendSystime)).orElse(new EmptyType()))); + + return new StructType(values); + } + + public static ElectricalEnergyMeasurementClusterEnergyMeasurementStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Long energy = null; + Optional startTimestamp = Optional.empty(); + Optional endTimestamp = Optional.empty(); + Optional startSystime = Optional.empty(); + Optional endSystime = Optional.empty(); + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == ENERGY_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + energy = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == START_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + startTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == END_TIMESTAMP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + endTimestamp = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == START_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + startSystime = Optional.of(castingValue.value(Long.class)); + } + } else if (element.contextTagNum() == END_SYSTIME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + endSystime = Optional.of(castingValue.value(Long.class)); + } + } + } + return new ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("ElectricalEnergyMeasurementClusterEnergyMeasurementStruct {\n"); + output.append("\tenergy: "); + output.append(energy); + output.append("\n"); + output.append("\tstartTimestamp: "); + output.append(startTimestamp); + output.append("\n"); + output.append("\tendTimestamp: "); + output.append(endTimestamp); + output.append("\n"); + output.append("\tstartSystime: "); + output.append(startSystime); + output.append("\n"); + output.append("\tendSystime: "); + output.append(endSystime); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} public static class DemandResponseLoadControlClusterHeatingSourceControlStruct { public Integer heatingSource; private static final long HEATING_SOURCE_ID = 0L; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index 96f0183b3dadf3..cfdcfa8a6434d7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -223,6 +223,9 @@ public static BaseCluster getCluster(long clusterId) { if (clusterId == ValveConfigurationAndControl.ID) { return new ValveConfigurationAndControl(); } + if (clusterId == ElectricalEnergyMeasurement.ID) { + return new ElectricalEnergyMeasurement(); + } if (clusterId == DemandResponseLoadControl.ID) { return new DemandResponseLoadControl(); } @@ -9038,6 +9041,113 @@ public long getCommandID(String name) throws IllegalArgumentException { return Command.valueOf(name).getID(); } } + public static class ElectricalEnergyMeasurement implements BaseCluster { + public static final long ID = 145L; + public long getID() { + return ID; + } + + public enum Attribute { + Accuracy(0L), + CumulativeEnergyImported(1L), + CumulativeEnergyExported(2L), + PeriodicEnergyImported(3L), + PeriodicEnergyExported(4L), + GeneratedCommandList(65528L), + AcceptedCommandList(65529L), + EventList(65530L), + AttributeList(65531L), + FeatureMap(65532L), + ClusterRevision(65533L),; + private final long id; + Attribute(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Attribute value(long id) throws NoSuchFieldError { + for (Attribute attribute : Attribute.values()) { + if (attribute.getID() == id) { + return attribute; + } + } + throw new NoSuchFieldError(); + } + } + + public enum Event { + CumulativeEnergyMeasured(0L), + PeriodicEnergyMeasured(1L),; + private final long id; + Event(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Event value(long id) throws NoSuchFieldError { + for (Event event : Event.values()) { + if (event.getID() == id) { + return event; + } + } + throw new NoSuchFieldError(); + } + } + + public enum Command {; + private final long id; + Command(long id) { + this.id = id; + } + + public long getID() { + return id; + } + + public static Command value(long id) throws NoSuchFieldError { + for (Command command : Command.values()) { + if (command.getID() == id) { + return command; + } + } + throw new NoSuchFieldError(); + } + }@Override + public String getAttributeName(long id) throws NoSuchFieldError { + return Attribute.value(id).toString(); + } + + @Override + public String getEventName(long id) throws NoSuchFieldError { + return Event.value(id).toString(); + } + + @Override + public String getCommandName(long id) throws NoSuchFieldError { + return Command.value(id).toString(); + } + + @Override + public long getAttributeID(String name) throws IllegalArgumentException { + return Attribute.valueOf(name).getID(); + } + + @Override + public long getEventID(String name) throws IllegalArgumentException { + return Event.valueOf(name).getID(); + } + + @Override + public long getCommandID(String name) throws IllegalArgumentException { + return Command.valueOf(name).getID(); + } + } public static class DemandResponseLoadControl implements BaseCluster { public static final long ID = 150L; public long getID() { @@ -16337,7 +16447,8 @@ public static Attribute value(long id) throws NoSuchFieldError { } } - public enum Event {; + public enum Event { + PingCountEvent(0L),; private final long id; Event(long id) { this.id = id; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index db477f41ca12bd..27b051c993d5f5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -10008,6 +10008,195 @@ public void onError(Exception ex) { } } + public static class DelegatedElectricalEnergyMeasurementClusterAccuracyAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.AccuracyAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedElectricalEnergyMeasurementClusterCumulativeEnergyImportedAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.CumulativeEnergyImportedAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedElectricalEnergyMeasurementClusterCumulativeEnergyExportedAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.CumulativeEnergyExportedAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedElectricalEnergyMeasurementClusterPeriodicEnergyImportedAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.PeriodicEnergyImportedAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedElectricalEnergyMeasurementClusterPeriodicEnergyExportedAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.PeriodicEnergyExportedAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedElectricalEnergyMeasurementClusterGeneratedCommandListAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.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 DelegatedElectricalEnergyMeasurementClusterAcceptedCommandListAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.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 DelegatedElectricalEnergyMeasurementClusterEventListAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.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 DelegatedElectricalEnergyMeasurementClusterAttributeListAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.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 DelegatedDemandResponseLoadControlClusterLoadControlProgramsAttributeCallback implements ChipClusters.DemandResponseLoadControlCluster.LoadControlProgramsAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -19302,6 +19491,10 @@ public Map initializeClusterMap() { (ptr, endpointId) -> new ChipClusters.ValveConfigurationAndControlCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("valveConfigurationAndControl", valveConfigurationAndControlClusterInfo); + ClusterInfo electricalEnergyMeasurementClusterInfo = new ClusterInfo( + (ptr, endpointId) -> new ChipClusters.ElectricalEnergyMeasurementCluster(ptr, endpointId), new HashMap<>()); + clusterMap.put("electricalEnergyMeasurement", electricalEnergyMeasurementClusterInfo); + ClusterInfo demandResponseLoadControlClusterInfo = new ClusterInfo( (ptr, endpointId) -> new ChipClusters.DemandResponseLoadControlCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("demandResponseLoadControl", demandResponseLoadControlClusterInfo); @@ -19555,6 +19748,7 @@ public void combineCommand(Map destination, Map> getCommandMap() { commandMap.put("valveConfigurationAndControl", valveConfigurationAndControlClusterInteractionInfoMap); + Map electricalEnergyMeasurementClusterInteractionInfoMap = new LinkedHashMap<>(); + + commandMap.put("electricalEnergyMeasurement", electricalEnergyMeasurementClusterInteractionInfoMap); + Map demandResponseLoadControlClusterInteractionInfoMap = new LinkedHashMap<>(); Map demandResponseLoadControlregisterLoadControlProgramRequestCommandParams = new LinkedHashMap(); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 2ac1dab0489c80..fecf9c31d761ee 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -8931,6 +8931,76 @@ private static Map readValveConfigurationAndControlInte return result; } + private static Map readElectricalEnergyMeasurementInteractionInfo() { + Map result = new LinkedHashMap<>();Map readElectricalEnergyMeasurementGeneratedCommandListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalEnergyMeasurementGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalEnergyMeasurementCluster) cluster).readGeneratedCommandListAttribute( + (ChipClusters.ElectricalEnergyMeasurementCluster.GeneratedCommandListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalEnergyMeasurementClusterGeneratedCommandListAttributeCallback(), + readElectricalEnergyMeasurementGeneratedCommandListCommandParams + ); + result.put("readGeneratedCommandListAttribute", readElectricalEnergyMeasurementGeneratedCommandListAttributeInteractionInfo); + Map readElectricalEnergyMeasurementAcceptedCommandListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalEnergyMeasurementAcceptedCommandListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalEnergyMeasurementCluster) cluster).readAcceptedCommandListAttribute( + (ChipClusters.ElectricalEnergyMeasurementCluster.AcceptedCommandListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalEnergyMeasurementClusterAcceptedCommandListAttributeCallback(), + readElectricalEnergyMeasurementAcceptedCommandListCommandParams + ); + result.put("readAcceptedCommandListAttribute", readElectricalEnergyMeasurementAcceptedCommandListAttributeInteractionInfo); + Map readElectricalEnergyMeasurementEventListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalEnergyMeasurementEventListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalEnergyMeasurementCluster) cluster).readEventListAttribute( + (ChipClusters.ElectricalEnergyMeasurementCluster.EventListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalEnergyMeasurementClusterEventListAttributeCallback(), + readElectricalEnergyMeasurementEventListCommandParams + ); + result.put("readEventListAttribute", readElectricalEnergyMeasurementEventListAttributeInteractionInfo); + Map readElectricalEnergyMeasurementAttributeListCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalEnergyMeasurementAttributeListAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalEnergyMeasurementCluster) cluster).readAttributeListAttribute( + (ChipClusters.ElectricalEnergyMeasurementCluster.AttributeListAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedElectricalEnergyMeasurementClusterAttributeListAttributeCallback(), + readElectricalEnergyMeasurementAttributeListCommandParams + ); + result.put("readAttributeListAttribute", readElectricalEnergyMeasurementAttributeListAttributeInteractionInfo); + Map readElectricalEnergyMeasurementFeatureMapCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalEnergyMeasurementFeatureMapAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalEnergyMeasurementCluster) cluster).readFeatureMapAttribute( + (ChipClusters.LongAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + readElectricalEnergyMeasurementFeatureMapCommandParams + ); + result.put("readFeatureMapAttribute", readElectricalEnergyMeasurementFeatureMapAttributeInteractionInfo); + Map readElectricalEnergyMeasurementClusterRevisionCommandParams = new LinkedHashMap(); + InteractionInfo readElectricalEnergyMeasurementClusterRevisionAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.ElectricalEnergyMeasurementCluster) cluster).readClusterRevisionAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readElectricalEnergyMeasurementClusterRevisionCommandParams + ); + result.put("readClusterRevisionAttribute", readElectricalEnergyMeasurementClusterRevisionAttributeInteractionInfo); + + return result; + } private static Map readDemandResponseLoadControlInteractionInfo() { Map result = new LinkedHashMap<>();Map readDemandResponseLoadControlLoadControlProgramsCommandParams = new LinkedHashMap(); InteractionInfo readDemandResponseLoadControlLoadControlProgramsAttributeInteractionInfo = new InteractionInfo( @@ -19392,6 +19462,7 @@ public Map> getReadAttributeMap() { put("activatedCarbonFilterMonitoring", readActivatedCarbonFilterMonitoringInteractionInfo()); put("booleanSensorConfiguration", readBooleanSensorConfigurationInteractionInfo()); put("valveConfigurationAndControl", readValveConfigurationAndControlInteractionInfo()); + put("electricalEnergyMeasurement", readElectricalEnergyMeasurementInteractionInfo()); put("demandResponseLoadControl", readDemandResponseLoadControlInteractionInfo()); put("deviceEnergyManagement", readDeviceEnergyManagementInteractionInfo()); put("energyEvse", readEnergyEvseInteractionInfo()); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java index c0e34bf7f9d89b..5c6174336ce03a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java @@ -1278,6 +1278,8 @@ public Map> getWriteAttributeMap() { ); writeValveConfigurationAndControlInteractionInfo.put("writeOpenLevelAttribute", writeValveConfigurationAndControlOpenLevelAttributeInteractionInfo); writeAttributeMap.put("valveConfigurationAndControl", writeValveConfigurationAndControlInteractionInfo); + Map writeElectricalEnergyMeasurementInteractionInfo = new LinkedHashMap<>(); + writeAttributeMap.put("electricalEnergyMeasurement", writeElectricalEnergyMeasurementInteractionInfo); Map writeDemandResponseLoadControlInteractionInfo = new LinkedHashMap<>(); Map writeDemandResponseLoadControlDefaultRandomStartCommandParams = new LinkedHashMap(); CommandParameterInfo demandResponseLoadControldefaultRandomStartCommandParameterInfo = diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt new file mode 100644 index 00000000000000..8e0a4253bbc183 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -0,0 +1,96 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.eventstructs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + val energyImported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") + append("\tenergyImported : $energyImported\n") + append("\tenergyExported : $energyExported\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (energyImported.isPresent) { + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } + if (energyExported.isPresent) { + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } + endStructure() + } + } + + companion object { + private const val TAG_ENERGY_IMPORTED = 0 + private const val TAG_ENERGY_EXPORTED = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + tlvReader.enterStructure(tlvTag) + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt new file mode 100644 index 00000000000000..a2ffd06d482dc8 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -0,0 +1,96 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.eventstructs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + val energyImported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") + append("\tenergyImported : $energyImported\n") + append("\tenergyExported : $energyExported\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (energyImported.isPresent) { + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } + if (energyExported.isPresent) { + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } + endStructure() + } + } + + companion object { + private const val TAG_ENERGY_IMPORTED = 0 + private const val TAG_ENERGY_EXPORTED = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + tlvReader.enterStructure(tlvTag) + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt new file mode 100644 index 00000000000000..a0588f4ad66d56 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -0,0 +1,56 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.eventstructs + +import chip.devicecontroller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SampleMeiClusterPingCountEventEvent(val count: ULong, val fabricIndex: UInt) { + override fun toString(): String = buildString { + append("SampleMeiClusterPingCountEventEvent {\n") + append("\tcount : $count\n") + append("\tfabricIndex : $fabricIndex\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_COUNT), count) + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + endStructure() + } + } + + companion object { + private const val TAG_COUNT = 1 + private const val TAG_FABRIC_INDEX = 254 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { + tlvReader.enterStructure(tlvTag) + val count = tlvReader.getULong(ContextSpecificTag(TAG_COUNT)) + val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + + tlvReader.exitContainer() + + return SampleMeiClusterPingCountEventEvent(count, fabricIndex) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni index a7049a39a43861..6180ecae906183 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -53,6 +53,9 @@ structs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt", @@ -140,6 +143,8 @@ eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt", @@ -164,6 +169,7 @@ eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterScopedLoadControlEventStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterScopedLoadControlEventStruct.kt deleted file mode 100644 index 6a02cd2f755090..00000000000000 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterScopedLoadControlEventStruct.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * 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. - */ -package chip.devicecontroller.cluster.structs - -import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvReader -import matter.tlv.TlvWriter - -class DemandResponseLoadControlClusterScopedLoadControlEventStruct( - val eventID: ByteArray, - val programControl: ByteArray, - val control: UInt, - val deviceClass: ULong, - val enrollmentGroup: UInt?, - val criticality: UInt, - val startTime: ULong?, - val transitions: List, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { - append("DemandResponseLoadControlClusterScopedLoadControlEventStruct {\n") - append("\teventID : $eventID\n") - append("\tprogramControl : $programControl\n") - append("\tcontrol : $control\n") - append("\tdeviceClass : $deviceClass\n") - append("\tenrollmentGroup : $enrollmentGroup\n") - append("\tcriticality : $criticality\n") - append("\tstartTime : $startTime\n") - append("\ttransitions : $transitions\n") - append("\tfabricIndex : $fabricIndex\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_EVENT_I_D), eventID) - put(ContextSpecificTag(TAG_PROGRAM_CONTROL), programControl) - put(ContextSpecificTag(TAG_CONTROL), control) - put(ContextSpecificTag(TAG_DEVICE_CLASS), deviceClass) - if (enrollmentGroup != null) { - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) - } else { - putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } - put(ContextSpecificTag(TAG_CRITICALITY), criticality) - if (startTime != null) { - put(ContextSpecificTag(TAG_START_TIME), startTime) - } else { - putNull(ContextSpecificTag(TAG_START_TIME)) - } - startArray(ContextSpecificTag(TAG_TRANSITIONS)) - for (item in transitions.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - endStructure() - } - } - - companion object { - private const val TAG_EVENT_I_D = 0 - private const val TAG_PROGRAM_CONTROL = 1 - private const val TAG_CONTROL = 2 - private const val TAG_DEVICE_CLASS = 3 - private const val TAG_ENROLLMENT_GROUP = 4 - private const val TAG_CRITICALITY = 5 - private const val TAG_START_TIME = 6 - private const val TAG_TRANSITIONS = 7 - private const val TAG_FABRIC_INDEX = 254 - - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterScopedLoadControlEventStruct { - tlvReader.enterStructure(tlvTag) - val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programControl = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_CONTROL)) - val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val deviceClass = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - - tlvReader.exitContainer() - - return DemandResponseLoadControlClusterScopedLoadControlEventStruct( - eventID, - programControl, - control, - deviceClass, - enrollmentGroup, - criticality, - startTime, - transitions, - fabricIndex - ) - } - } -} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt new file mode 100644 index 00000000000000..bbce3fc7d16ff7 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -0,0 +1,116 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + val energy: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterEnergyMeasurementStruct {\n") + append("\tenergy : $energy\n") + append("\tstartTimestamp : $startTimestamp\n") + append("\tendTimestamp : $endTimestamp\n") + append("\tstartSystime : $startSystime\n") + append("\tendSystime : $endSystime\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_ENERGY), energy) + if (startTimestamp.isPresent) { + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } + if (endTimestamp.isPresent) { + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } + if (startSystime.isPresent) { + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } + if (endSystime.isPresent) { + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } + endStructure() + } + } + + companion object { + private const val TAG_ENERGY = 0 + private const val TAG_START_TIMESTAMP = 1 + private const val TAG_END_TIMESTAMP = 2 + private const val TAG_START_SYSTIME = 3 + private const val TAG_END_SYSTIME = 4 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + tlvReader.enterStructure(tlvTag) + val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt new file mode 100644 index 00000000000000..8ce0529f9cd457 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -0,0 +1,150 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct {\n") + append("\trangeMin : $rangeMin\n") + append("\trangeMax : $rangeMax\n") + append("\tpercentMax : $percentMax\n") + append("\tpercentMin : $percentMin\n") + append("\tpercentTypical : $percentTypical\n") + append("\tfixedMax : $fixedMax\n") + append("\tfixedMin : $fixedMin\n") + append("\tfixedTypical : $fixedTypical\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) + put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) + if (percentMax.isPresent) { + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } + if (percentMin.isPresent) { + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } + if (percentTypical.isPresent) { + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } + if (fixedMax.isPresent) { + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } + if (fixedMin.isPresent) { + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } + if (fixedTypical.isPresent) { + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } + endStructure() + } + } + + companion object { + private const val TAG_RANGE_MIN = 0 + private const val TAG_RANGE_MAX = 1 + private const val TAG_PERCENT_MAX = 2 + private const val TAG_PERCENT_MIN = 3 + private const val TAG_PERCENT_TYPICAL = 4 + private const val TAG_FIXED_MAX = 5 + private const val TAG_FIXED_MIN = 6 + private const val TAG_FIXED_TYPICAL = 7 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + tlvReader.enterStructure(tlvTag) + val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) + val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt new file mode 100644 index 00000000000000..3c33b23cb9e505 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -0,0 +1,100 @@ +/* + * + * 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. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UInt, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct {\n") + append("\tmeasurementType : $measurementType\n") + append("\tmeasured : $measured\n") + append("\tminMeasuredValue : $minMeasuredValue\n") + append("\tmaxMeasuredValue : $maxMeasuredValue\n") + append("\taccuracyRanges : $accuracyRanges\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_MEASUREMENT_TYPE), measurementType) + put(ContextSpecificTag(TAG_MEASURED), measured) + put(ContextSpecificTag(TAG_MIN_MEASURED_VALUE), minMeasuredValue) + put(ContextSpecificTag(TAG_MAX_MEASURED_VALUE), maxMeasuredValue) + startArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + for (item in accuracyRanges.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + endStructure() + } + } + + companion object { + private const val TAG_MEASUREMENT_TYPE = 0 + private const val TAG_MEASURED = 1 + private const val TAG_MIN_MEASURED_VALUE = 2 + private const val TAG_MAX_MEASURED_VALUE = 3 + private const val TAG_ACCURACY_RANGES = 4 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + tlvReader.enterStructure(tlvTag) + val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) + val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) + val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) + val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt deleted file mode 100644 index 385f331a718700..00000000000000 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * 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. - */ -package chip.devicecontroller.cluster.structs - -import chip.devicecontroller.cluster.* -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvReader -import matter.tlv.TlvWriter - -class ThermostatClusterThermostatScheduleTransition( - val transitionTime: UInt, - val heatSetpoint: Int?, - val coolSetpoint: Int? -) { - override fun toString(): String = buildString { - append("ThermostatClusterThermostatScheduleTransition {\n") - append("\ttransitionTime : $transitionTime\n") - append("\theatSetpoint : $heatSetpoint\n") - append("\tcoolSetpoint : $coolSetpoint\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) - if (heatSetpoint != null) { - put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) - } else { - putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } - if (coolSetpoint != null) { - put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) - } else { - putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - } - endStructure() - } - } - - companion object { - private const val TAG_TRANSITION_TIME = 0 - private const val TAG_HEAT_SETPOINT = 1 - private const val TAG_COOL_SETPOINT = 2 - - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterThermostatScheduleTransition { - tlvReader.enterStructure(tlvTag) - val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - - tlvReader.exitContainer() - - return ThermostatClusterThermostatScheduleTransition( - transitionTime, - heatSetpoint, - coolSetpoint - ) - } - } -} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt new file mode 100644 index 00000000000000..fc11bce628093a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt @@ -0,0 +1,544 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class AccessControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AclAttribute(val value: List) + + class ExtensionAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readAclAttribute(): AclAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acl attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return AclAttribute(decodedValue) + } + + suspend fun writeAclAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readExtensionAttribute(): ExtensionAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Extension attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ExtensionAttribute(decodedValue) + } + + suspend fun writeExtensionAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 1u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readTargetsPerAccessControlEntryAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Targetsperaccesscontrolentry attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readAccessControlEntriesPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(AccessControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 31u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt new file mode 100644 index 00000000000000..f0116402eca67a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt @@ -0,0 +1,372 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class AccountLoginCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GetSetupPINResponse(val setupPIN: String) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun getSetupPIN( + tempAccountIdentifier: String, + timedInvokeTimeoutMs: Int + ): GetSetupPINResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TEMP_ACCOUNT_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_SETUP_P_I_N: Int = 0 + var setupPIN_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) { + setupPIN_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (setupPIN_decoded == null) { + throw IllegalStateException("setupPIN not found in TLV") + } + + tlvReader.exitContainer() + + return GetSetupPINResponse(setupPIN_decoded) + } + + suspend fun login( + tempAccountIdentifier: String, + setupPIN: String, + node: ULong?, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TEMP_ACCOUNT_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) + + val TAG_SETUP_P_I_N_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SETUP_P_I_N_REQ), setupPIN) + + val TAG_NODE_REQ: Int = 2 + node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun logout(node: ULong?, timedInvokeTimeoutMs: Int) { + val commandId: UInt = 3u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NODE_REQ: Int = 0 + node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(AccountLoginCluster::class.java.name) + const val CLUSTER_ID: UInt = 1294u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt new file mode 100644 index 00000000000000..95bd3e795544a3 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt @@ -0,0 +1,731 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) { + class ActionListAttribute(val value: List) + + class EndpointListsAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun instantAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun instantActionWithTransition( + actionID: UShort, + invokeID: UInt?, + transitionTime: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun startActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + + val TAG_DURATION_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun pauseActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + + val TAG_DURATION_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun resumeAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enableActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + + val TAG_DURATION_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun disableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 10u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun disableActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 11u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ACTION_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) + + val TAG_INVOKE_I_D_REQ: Int = 1 + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + + val TAG_DURATION_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readActionListAttribute(): ActionListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Actionlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return ActionListAttribute(decodedValue) + } + + suspend fun readEndpointListsAttribute(): EndpointListsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Endpointlists attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return EndpointListsAttribute(decodedValue) + } + + suspend fun readSetupURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Setupurl attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ActionsCluster::class.java.name) + const val CLUSTER_ID: UInt = 37u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt new file mode 100644 index 00000000000000..a975d6d3c0672b --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt @@ -0,0 +1,563 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ActivatedCarbonFilterMonitoringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LastChangedTimeAttribute(val value: UInt?) + + class ReplacementProductListAttribute( + val value: List? + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun resetCondition(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readConditionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Condition attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDegradationDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readChangeIndicationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Changeindication attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readInPlaceIndicatorAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LastChangedTimeAttribute(decodedValue) + } + + suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ReplacementProductListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ActivatedCarbonFilterMonitoringCluster::class.java.name) + const val CLUSTER_ID: UInt = 114u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt new file mode 100644 index 00000000000000..0044a16f906070 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt @@ -0,0 +1,460 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class AdministratorCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AdminFabricIndexAttribute(val value: UByte?) + + class AdminVendorIdAttribute(val value: UShort?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun openCommissioningWindow( + commissioningTimeout: UShort, + PAKEPasscodeVerifier: ByteArray, + discriminator: UShort, + iterations: UInt, + salt: ByteArray, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_COMMISSIONING_TIMEOUT_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) + + val TAG_P_A_K_E_PASSCODE_VERIFIER_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_P_A_K_E_PASSCODE_VERIFIER_REQ), PAKEPasscodeVerifier) + + val TAG_DISCRIMINATOR_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DISCRIMINATOR_REQ), discriminator) + + val TAG_ITERATIONS_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_ITERATIONS_REQ), iterations) + + val TAG_SALT_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun openBasicCommissioningWindow( + commissioningTimeout: UShort, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_COMMISSIONING_TIMEOUT_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun revokeCommissioning(timedInvokeTimeoutMs: Int) { + val commandId: UInt = 2u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readWindowStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Windowstatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Adminfabricindex attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AdminFabricIndexAttribute(decodedValue) + } + + suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Adminvendorid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AdminVendorIdAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(AdministratorCommissioningCluster::class.java.name) + const val CLUSTER_ID: UInt = 60u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt new file mode 100644 index 00000000000000..c9f7b320e2eafa --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt @@ -0,0 +1,288 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readAirQualityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Airquality attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(AirQualityCluster::class.java.name) + const val CLUSTER_ID: UInt = 91u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt new file mode 100644 index 00000000000000..8971387efd222a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt @@ -0,0 +1,535 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class ApplicationBasicCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ApplicationAttribute(val value: ApplicationBasicClusterApplicationStruct) + + class AllowedVendorListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readVendorNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readVendorIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readApplicationNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Applicationname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readProductIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readApplicationAttribute(): ApplicationAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Application attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ApplicationBasicClusterApplicationStruct = + ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) + + return ApplicationAttribute(decodedValue) + } + + suspend fun readStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Status attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readApplicationVersionAttribute(): String { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Applicationversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Allowedvendorlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AllowedVendorListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ApplicationBasicCluster::class.java.name) + const val CLUSTER_ID: UInt = 1293u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt new file mode 100644 index 00000000000000..73314cd4a1dd90 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt @@ -0,0 +1,560 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ApplicationLauncherCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LauncherResponse(val status: UByte, val data: ByteArray?) + + class CatalogListAttribute(val value: List?) + + class CurrentAppAttribute(val value: ApplicationLauncherClusterApplicationEPStruct?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun launchApp( + application: ApplicationLauncherClusterApplicationStruct?, + data: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): LauncherResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_APPLICATION_REQ: Int = 0 + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } + + val TAG_DATA_REQ: Int = 1 + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return LauncherResponse(status_decoded, data_decoded) + } + + suspend fun stopApp( + application: ApplicationLauncherClusterApplicationStruct?, + timedInvokeTimeoutMs: Int? = null + ): LauncherResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_APPLICATION_REQ: Int = 0 + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return LauncherResponse(status_decoded, data_decoded) + } + + suspend fun hideApp( + application: ApplicationLauncherClusterApplicationStruct?, + timedInvokeTimeoutMs: Int? = null + ): LauncherResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_APPLICATION_REQ: Int = 0 + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return LauncherResponse(status_decoded, data_decoded) + } + + suspend fun readCatalogListAttribute(): CatalogListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Cataloglist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return CatalogListAttribute(decodedValue) + } + + suspend fun readCurrentAppAttribute(): CurrentAppAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentapp attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentAppAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ApplicationLauncherCluster::class.java.name) + const val CLUSTER_ID: UInt = 1292u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt new file mode 100644 index 00000000000000..ab200b7240d730 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt @@ -0,0 +1,383 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) { + class OutputListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun selectOutput(index: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun renameOutput(index: UByte, name: String, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + + val TAG_NAME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readOutputListAttribute(): OutputListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Outputlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return OutputListAttribute(decodedValue) + } + + suspend fun readCurrentOutputAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentoutput attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(AudioOutputCluster::class.java.name) + const val CLUSTER_ID: UInt = 1291u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt new file mode 100644 index 00000000000000..439e459f36a99f --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt @@ -0,0 +1,1202 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BallastConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class IntrinsicBallastFactorAttribute(val value: UByte?) + + class BallastFactorAdjustmentAttribute(val value: UByte?) + + class LampRatedHoursAttribute(val value: UInt?) + + class LampBurnHoursAttribute(val value: UInt?) + + class LampBurnHoursTripPointAttribute(val value: UInt?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readPhysicalMinLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Physicalminlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readPhysicalMaxLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Physicalmaxlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readBallastStatusAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ballaststatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMinLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeMinLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readMaxLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeMaxLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 17u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Intrinsicballastfactor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return IntrinsicBallastFactorAttribute(decodedValue) + } + + suspend fun writeIntrinsicBallastFactorAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 20u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ballastfactoradjustment attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BallastFactorAdjustmentAttribute(decodedValue) + } + + suspend fun writeBallastFactorAdjustmentAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 21u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLampQuantityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lampquantity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readLampTypeAttribute(): String? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lamptype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLampTypeAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 48u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLampManufacturerAttribute(): String? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lampmanufacturer attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLampManufacturerAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 49u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lampratedhours attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LampRatedHoursAttribute(decodedValue) + } + + suspend fun writeLampRatedHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 50u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lampburnhours attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LampBurnHoursAttribute(decodedValue) + } + + suspend fun writeLampBurnHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 51u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLampAlarmModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lampalarmmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLampAlarmModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 52u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lampburnhourstrippoint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LampBurnHoursTripPointAttribute(decodedValue) + } + + suspend fun writeLampBurnHoursTripPointAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 53u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BallastConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 769u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt new file mode 100644 index 00000000000000..e75a765a299b32 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt @@ -0,0 +1,910 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BarrierControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun barrierControlGoToPercent(percentOpen: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_PERCENT_OPEN_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun barrierControlStop(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readBarrierMovingStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriermovingstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readBarrierSafetyStatusAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriersafetystatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readBarrierCapabilitiesAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriercapabilities attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readBarrierOpenEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barrieropenevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeBarrierOpenEventsAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBarrierCloseEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriercloseevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeBarrierCloseEventsAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBarrierCommandOpenEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriercommandopenevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeBarrierCommandOpenEventsAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 6u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBarrierCommandCloseEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriercommandcloseevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeBarrierCommandCloseEventsAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 7u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBarrierOpenPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barrieropenperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeBarrierOpenPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 8u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBarrierClosePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barriercloseperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeBarrierClosePeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 9u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBarrierPositionAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Barrierposition attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BarrierControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 259u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt new file mode 100644 index 00000000000000..b7d485e630f295 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt @@ -0,0 +1,1177 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BasicInformationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CapabilityMinimaAttribute(val value: BasicInformationClusterCapabilityMinimaStruct) + + class ProductAppearanceAttribute(val value: BasicInformationClusterProductAppearanceStruct?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun mfgSpecificPing(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readDataModelRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Datamodelrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readVendorNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readVendorIDAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readProductNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readProductIDAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readNodeLabelAttribute(): String { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nodelabel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLocationAttribute(): String { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Location attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun writeLocationAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 6u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readHardwareVersionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readHardwareVersionStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readSoftwareVersionAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Softwareversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readSoftwareVersionStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readManufacturingDateAttribute(): String? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPartNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Partnumber attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readProductURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Producturl attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readProductLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productlabel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSerialNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Serialnumber attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLocalConfigDisabledAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Localconfigdisabled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLocalConfigDisabledAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readReachableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reachable attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUniqueIDAttribute(): String? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uniqueid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Capabilityminima attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = + BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) + + return CapabilityMinimaAttribute(decodedValue) + } + + suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productappearance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: BasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + + return ProductAppearanceAttribute(decodedValue) + } + + suspend fun readSpecificationVersionAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Specificationversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readMaxPathsPerInvokeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxpathsperinvoke attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BasicInformationCluster::class.java.name) + const val CLUSTER_ID: UInt = 40u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt new file mode 100644 index 00000000000000..724313e69f9864 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt @@ -0,0 +1,826 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BinaryInputBasicCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readActiveTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activetext attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeActiveTextAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readDescriptionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Description attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeDescriptionAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 28u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInactiveTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 46u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Inactivetext attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeInactiveTextAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 46u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOutOfServiceAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 81u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Outofservice attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeOutOfServiceAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 81u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPolarityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 84u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Polarity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPresentValueAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 85u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Presentvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writePresentValueAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 85u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readReliabilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 103u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reliability attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeReliabilityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 103u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readStatusFlagsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 111u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Statusflags attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readApplicationTypeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 256u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Applicationtype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BinaryInputBasicCluster::class.java.name) + const val CLUSTER_ID: UInt = 15u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt new file mode 100644 index 00000000000000..0080e10783e5a0 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt @@ -0,0 +1,351 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BindingCluster(private val controller: MatterController, private val endpointId: UShort) { + class BindingAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readBindingAttribute(): BindingAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Binding attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return BindingAttribute(decodedValue) + } + + suspend fun writeBindingAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BindingCluster::class.java.name) + const val CLUSTER_ID: UInt = 30u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanSensorConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanSensorConfigurationCluster.kt new file mode 100644 index 00000000000000..bee6e840c56b61 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanSensorConfigurationCluster.kt @@ -0,0 +1,520 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BooleanSensorConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun suppressRequest(alarmsToSuppress: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ALARMS_TO_SUPPRESS_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sensitivitylevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeSensitivityLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAlarmsActiveAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Alarmsactive attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAlarmsSuppressedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Alarmssuppressed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAlarmsEnabledAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Alarmsenabled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeAlarmsEnabledAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BooleanSensorConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 128u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt new file mode 100644 index 00000000000000..19e1e5207f5d29 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt @@ -0,0 +1,291 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class BooleanStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readStateValueAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Statevalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BooleanStateCluster::class.java.name) + const val CLUSTER_ID: UInt = 69u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt new file mode 100644 index 00000000000000..e80a25e74f32c8 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt @@ -0,0 +1,882 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class BridgedDeviceBasicInformationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ProductAppearanceAttribute( + val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readVendorNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readVendorIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readProductNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNodeLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nodelabel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readHardwareVersionAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readHardwareVersionStringAttribute(): String? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSoftwareVersionAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Softwareversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSoftwareVersionStringAttribute(): String? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readManufacturingDateAttribute(): String? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPartNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Partnumber attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readProductURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Producturl attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readProductLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productlabel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSerialNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Serialnumber attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readReachableAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reachable attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readUniqueIDAttribute(): String? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uniqueid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Productappearance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + + return ProductAppearanceAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(BridgedDeviceBasicInformationCluster::class.java.name) + const val CLUSTER_ID: UInt = 57u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..d76d7309276360 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt @@ -0,0 +1,692 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class CarbonDioxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1037u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..e52a35e6e5cc80 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt @@ -0,0 +1,692 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class CarbonMonoxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1036u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt new file mode 100644 index 00000000000000..d09b34301d14de --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt @@ -0,0 +1,708 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ChannelCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeChannelResponse(val status: UByte, val data: String?) + + class ProgramGuideResponse( + val channelPagingStruct: Short, + val programList: List + ) + + class ChannelListAttribute(val value: List?) + + class LineupAttribute(val value: ChannelClusterLineupInfoStruct?) + + class CurrentChannelAttribute(val value: ChannelClusterChannelInfoStruct?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeChannel( + match: String, + timedInvokeTimeoutMs: Int? = null + ): ChangeChannelResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MATCH_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeChannelResponse(status_decoded, data_decoded) + } + + suspend fun changeChannelByNumber( + majorNumber: UShort, + minorNumber: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MAJOR_NUMBER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MAJOR_NUMBER_REQ), majorNumber) + + val TAG_MINOR_NUMBER_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun skipChannel(count: Short, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_COUNT_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getProgramGuide( + startTime: UInt?, + endTime: UInt?, + channelList: List?, + pageToken: ChannelClusterPageTokenStruct?, + recordingFlag: UInt?, + externalIDList: List?, + data: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): ProgramGuideResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_START_TIME_REQ: Int = 0 + startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) } + + val TAG_END_TIME_REQ: Int = 1 + endTime?.let { tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) } + + val TAG_CHANNEL_LIST_REQ: Int = 2 + channelList?.let { + tlvWriter.startArray(ContextSpecificTag(TAG_CHANNEL_LIST_REQ)) + for (item in channelList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + } + + val TAG_PAGE_TOKEN_REQ: Int = 3 + pageToken?.let { pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) } + + val TAG_RECORDING_FLAG_REQ: Int = 4 + recordingFlag?.let { tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) } + + val TAG_EXTERNAL_I_D_LIST_REQ: Int = 5 + externalIDList?.let { + tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + } + + val TAG_DATA_REQ: Int = 6 + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_CHANNEL_PAGING_STRUCT: Int = 0 + var channelPagingStruct_decoded: Short? = null + + val TAG_PROGRAM_LIST: Int = 1 + var programList_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_CHANNEL_PAGING_STRUCT)) { + channelPagingStruct_decoded = tlvReader.getShort(tag) + } + + if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) { + programList_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (channelPagingStruct_decoded == null) { + throw IllegalStateException("channelPagingStruct not found in TLV") + } + + if (programList_decoded == null) { + throw IllegalStateException("programList not found in TLV") + } + + tlvReader.exitContainer() + + return ProgramGuideResponse(channelPagingStruct_decoded, programList_decoded) + } + + suspend fun recordProgram( + programIdentifier: String, + shouldRecordSeries: Boolean, + externalIDList: List, + data: ByteArray, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_PROGRAM_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_PROGRAM_IDENTIFIER_REQ), programIdentifier) + + val TAG_SHOULD_RECORD_SERIES_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SHOULD_RECORD_SERIES_REQ), shouldRecordSeries) + + val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 + tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val TAG_DATA_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun cancelRecordProgram( + programIdentifier: String, + shouldRecordSeries: Boolean, + externalIDList: List, + data: ByteArray, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_PROGRAM_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_PROGRAM_IDENTIFIER_REQ), programIdentifier) + + val TAG_SHOULD_RECORD_SERIES_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SHOULD_RECORD_SERIES_REQ), shouldRecordSeries) + + val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 + tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val TAG_DATA_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readChannelListAttribute(): ChannelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Channellist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ChannelListAttribute(decodedValue) + } + + suspend fun readLineupAttribute(): LineupAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lineup attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ChannelClusterLineupInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LineupAttribute(decodedValue) + } + + suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentchannel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ChannelClusterChannelInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentChannelAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ChannelCluster::class.java.name) + const val CLUSTER_ID: UInt = 1284u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt new file mode 100644 index 00000000000000..2491ef6cf88e71 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt @@ -0,0 +1,3541 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ColorControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NumberOfPrimariesAttribute(val value: UByte?) + + class Primary1IntensityAttribute(val value: UByte?) + + class Primary2IntensityAttribute(val value: UByte?) + + class Primary3IntensityAttribute(val value: UByte?) + + class Primary4IntensityAttribute(val value: UByte?) + + class Primary5IntensityAttribute(val value: UByte?) + + class Primary6IntensityAttribute(val value: UByte?) + + class ColorPointRIntensityAttribute(val value: UByte?) + + class ColorPointGIntensityAttribute(val value: UByte?) + + class ColorPointBIntensityAttribute(val value: UByte?) + + class StartUpColorTemperatureMiredsAttribute(val value: UShort?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun moveToHue( + hue: UByte, + direction: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_HUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_HUE_REQ), hue) + + val TAG_DIRECTION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveHue( + moveMode: UByte, + rate: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MOVE_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) + + val TAG_RATE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stepHue( + stepMode: UByte, + stepSize: UByte, + transitionTime: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_MODE_REQ), stepMode) + + val TAG_STEP_SIZE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_SIZE_REQ), stepSize) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveToSaturation( + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SATURATION_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_SATURATION_REQ), saturation) + + val TAG_TRANSITION_TIME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveSaturation( + moveMode: UByte, + rate: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MOVE_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) + + val TAG_RATE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stepSaturation( + stepMode: UByte, + stepSize: UByte, + transitionTime: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_MODE_REQ), stepMode) + + val TAG_STEP_SIZE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_SIZE_REQ), stepSize) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveToHueAndSaturation( + hue: UByte, + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_HUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_HUE_REQ), hue) + + val TAG_SATURATION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SATURATION_REQ), saturation) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveToColor( + colorX: UShort, + colorY: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_COLOR_X_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_COLOR_X_REQ), colorX) + + val TAG_COLOR_Y_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_COLOR_Y_REQ), colorY) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveColor( + rateX: Short, + rateY: Short, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_RATE_X_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_RATE_X_REQ), rateX) + + val TAG_RATE_Y_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_RATE_Y_REQ), rateY) + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stepColor( + stepX: Short, + stepY: Short, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_X_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_X_REQ), stepX) + + val TAG_STEP_Y_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_Y_REQ), stepY) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveToColorTemperature( + colorTemperatureMireds: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 10u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_COLOR_TEMPERATURE_MIREDS_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MIREDS_REQ), colorTemperatureMireds) + + val TAG_TRANSITION_TIME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enhancedMoveToHue( + enhancedHue: UShort, + direction: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 64u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ENHANCED_HUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ENHANCED_HUE_REQ), enhancedHue) + + val TAG_DIRECTION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enhancedMoveHue( + moveMode: UByte, + rate: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 65u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MOVE_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) + + val TAG_RATE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enhancedStepHue( + stepMode: UByte, + stepSize: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 66u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_MODE_REQ), stepMode) + + val TAG_STEP_SIZE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_SIZE_REQ), stepSize) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enhancedMoveToHueAndSaturation( + enhancedHue: UShort, + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 67u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ENHANCED_HUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ENHANCED_HUE_REQ), enhancedHue) + + val TAG_SATURATION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SATURATION_REQ), saturation) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun colorLoopSet( + updateFlags: UByte, + action: UByte, + direction: UByte, + time: UShort, + startHue: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 68u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_UPDATE_FLAGS_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_UPDATE_FLAGS_REQ), updateFlags) + + val TAG_ACTION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ACTION_REQ), action) + + val TAG_DIRECTION_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) + + val TAG_TIME_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_TIME_REQ), time) + + val TAG_START_HUE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_START_HUE_REQ), startHue) + + val TAG_OPTIONS_MASK_REQ: Int = 5 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stopMoveStep( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 71u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPTIONS_MASK_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveColorTemperature( + moveMode: UByte, + rate: UShort, + colorTemperatureMinimumMireds: UShort, + colorTemperatureMaximumMireds: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 75u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MOVE_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) + + val TAG_RATE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) + + val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 2 + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), + colorTemperatureMinimumMireds + ) + + val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 3 + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), + colorTemperatureMaximumMireds + ) + + val TAG_OPTIONS_MASK_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 5 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stepColorTemperature( + stepMode: UByte, + stepSize: UShort, + transitionTime: UShort, + colorTemperatureMinimumMireds: UShort, + colorTemperatureMaximumMireds: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 76u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_MODE_REQ), stepMode) + + val TAG_STEP_SIZE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_SIZE_REQ), stepSize) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 3 + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), + colorTemperatureMinimumMireds + ) + + val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 4 + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), + colorTemperatureMaximumMireds + ) + + val TAG_OPTIONS_MASK_REQ: Int = 5 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readCurrentHueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currenthue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentSaturationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentsaturation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRemainingTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Remainingtime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentx attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currenty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDriftCompensationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Driftcompensation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCompensationTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Compensationtext attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorTemperatureMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colortemperaturemireds attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colormode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOptionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Options attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 15u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofprimaries attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NumberOfPrimariesAttribute(decodedValue) + } + + suspend fun readPrimary1XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary1x attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary1YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary1y attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary1intensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return Primary1IntensityAttribute(decodedValue) + } + + suspend fun readPrimary2XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary2x attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary2YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary2y attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary2intensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return Primary2IntensityAttribute(decodedValue) + } + + suspend fun readPrimary3XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary3x attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary3YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary3y attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary3intensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return Primary3IntensityAttribute(decodedValue) + } + + suspend fun readPrimary4XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary4x attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary4YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary4y attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary4intensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return Primary4IntensityAttribute(decodedValue) + } + + suspend fun readPrimary5XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary5x attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary5YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary5y attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary5intensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return Primary5IntensityAttribute(decodedValue) + } + + suspend fun readPrimary6XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary6x attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary6YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary6y attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Primary6intensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return Primary6IntensityAttribute(decodedValue) + } + + suspend fun readWhitePointXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Whitepointx attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeWhitePointXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 48u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readWhitePointYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Whitepointy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeWhitePointYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 49u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointRXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointrx attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeColorPointRXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 50u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointRYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointry attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeColorPointRYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 51u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointrintensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ColorPointRIntensityAttribute(decodedValue) + } + + suspend fun writeColorPointRIntensityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 52u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointGXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointgx attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeColorPointGXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 54u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointGYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointgy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeColorPointGYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 55u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointgintensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ColorPointGIntensityAttribute(decodedValue) + } + + suspend fun writeColorPointGIntensityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 56u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointBXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointbx attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeColorPointBXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 58u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointBYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 59u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointby attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeColorPointBYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 59u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { + val ATTRIBUTE_ID: UInt = 60u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorpointbintensity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ColorPointBIntensityAttribute(decodedValue) + } + + suspend fun writeColorPointBIntensityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 60u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnhancedCurrentHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enhancedcurrenthue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readEnhancedColorModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enhancedcolormode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readColorLoopActiveAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorloopactive attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorLoopDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorloopdirection attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorLoopTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorlooptime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16389u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorloopstartenhancedhue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16390u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorloopstoredenhancedhue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorCapabilitiesAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 16394u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colorcapabilities attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16395u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colortempphysicalminmireds attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16396u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Colortempphysicalmaxmireds attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16397u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute { + val ATTRIBUTE_ID: UInt = 16400u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpColorTemperatureMiredsAttribute(decodedValue) + } + + suspend fun writeStartUpColorTemperatureMiredsAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16400u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ColorControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 768u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt new file mode 100644 index 00000000000000..a855e05d3931e6 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt @@ -0,0 +1,350 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ContentAppObserverCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ContentAppMessageResponse(val status: UByte?, val data: String, val encodingHint: String) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun contentAppMessage( + data: String?, + encodingHint: String, + timedInvokeTimeoutMs: Int? = null + ): ContentAppMessageResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DATA_REQ: Int = 0 + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + + val TAG_ENCODING_HINT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + val TAG_ENCODING_HINT: Int = 2 + var encodingHint_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = tlvReader.getString(tag) + } + + if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) { + encodingHint_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (data_decoded == null) { + throw IllegalStateException("data not found in TLV") + } + + if (encodingHint_decoded == null) { + throw IllegalStateException("encodingHint not found in TLV") + } + + tlvReader.exitContainer() + + return ContentAppMessageResponse(status_decoded, data_decoded, encodingHint_decoded) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ContentAppObserverCluster::class.java.name) + const val CLUSTER_ID: UInt = 1296u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt new file mode 100644 index 00000000000000..d2385635fa97ed --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt @@ -0,0 +1,812 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ContentControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ResetPINResponse(val PINCode: String) + + class OnDemandRatingsAttribute(val value: List?) + + class ScheduledContentRatingsAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun updatePIN(oldPIN: String?, newPIN: String, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OLD_P_I_N_REQ: Int = 0 + oldPIN?.let { tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) } + + val TAG_NEW_P_I_N_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun resetPIN(timedInvokeTimeoutMs: Int? = null): ResetPINResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_P_I_N_CODE: Int = 0 + var PINCode_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) { + PINCode_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (PINCode_decoded == null) { + throw IllegalStateException("PINCode not found in TLV") + } + + tlvReader.exitContainer() + + return ResetPINResponse(PINCode_decoded) + } + + suspend fun enable(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun disable(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun addBonusTime(PINCode: String?, bonusTime: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_P_I_N_CODE_REQ: Int = 0 + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + + val TAG_BONUS_TIME_REQ: Int = 1 + bonusTime?.let { tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setScreenDailyTime(screenTime: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SCREEN_TIME_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun blockUnratedContent(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun unblockUnratedContent(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setOnDemandRatingThreshold(rating: String, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_RATING_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setScheduledContentRatingThreshold( + rating: String, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 10u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_RATING_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enabled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ondemandratings attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return OnDemandRatingsAttribute(decodedValue) + } + + suspend fun readOnDemandRatingThresholdAttribute(): String? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ondemandratingthreshold attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scheduledcontentratings attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ScheduledContentRatingsAttribute(decodedValue) + } + + suspend fun readScheduledContentRatingThresholdAttribute(): String? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readScreenDailyTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Screendailytime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRemainingScreenTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Remainingscreentime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBlockUnratedAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Blockunrated attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ContentControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 1295u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt new file mode 100644 index 00000000000000..cc570223e91c41 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt @@ -0,0 +1,512 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ContentLauncherCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LauncherResponse(val status: UByte, val data: String?) + + class AcceptHeaderAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun launchContent( + search: ContentLauncherClusterContentSearchStruct, + autoPlay: Boolean, + data: String?, + playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct?, + useCurrentContext: Boolean?, + timedInvokeTimeoutMs: Int? = null + ): LauncherResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SEARCH_REQ: Int = 0 + search.toTlv(ContextSpecificTag(TAG_SEARCH_REQ), tlvWriter) + + val TAG_AUTO_PLAY_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_AUTO_PLAY_REQ), autoPlay) + + val TAG_DATA_REQ: Int = 2 + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + + val TAG_PLAYBACK_PREFERENCES_REQ: Int = 3 + playbackPreferences?.let { + playbackPreferences.toTlv(ContextSpecificTag(TAG_PLAYBACK_PREFERENCES_REQ), tlvWriter) + } + + val TAG_USE_CURRENT_CONTEXT_REQ: Int = 4 + useCurrentContext?.let { + tlvWriter.put(ContextSpecificTag(TAG_USE_CURRENT_CONTEXT_REQ), useCurrentContext) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return LauncherResponse(status_decoded, data_decoded) + } + + suspend fun launchURL( + contentURL: String, + displayString: String?, + brandingInformation: ContentLauncherClusterBrandingInformationStruct?, + timedInvokeTimeoutMs: Int? = null + ): LauncherResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CONTENT_U_R_L_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_CONTENT_U_R_L_REQ), contentURL) + + val TAG_DISPLAY_STRING_REQ: Int = 1 + displayString?.let { tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) } + + val TAG_BRANDING_INFORMATION_REQ: Int = 2 + brandingInformation?.let { + brandingInformation.toTlv(ContextSpecificTag(TAG_BRANDING_INFORMATION_REQ), tlvWriter) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return LauncherResponse(status_decoded, data_decoded) + } + + suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptheader attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return AcceptHeaderAttribute(decodedValue) + } + + suspend fun readSupportedStreamingProtocolsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedstreamingprotocols attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ContentLauncherCluster::class.java.name) + const val CLUSTER_ID: UInt = 1290u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt new file mode 100644 index 00000000000000..0e1bd29d154949 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt @@ -0,0 +1,769 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DemandResponseLoadControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LoadControlProgramsAttribute( + val value: List + ) + + class EventsAttribute(val value: List) + + class ActiveEventsAttribute( + val value: List + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun registerLoadControlProgramRequest( + loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LOAD_CONTROL_PROGRAM_REQ: Int = 0 + loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun unregisterLoadControlProgramRequest( + loadControlProgramID: ByteArray, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LOAD_CONTROL_PROGRAM_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun addLoadControlEventRequest( + event: DemandResponseLoadControlClusterLoadControlEventStruct, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_EVENT_REQ: Int = 0 + event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun removeLoadControlEventRequest( + eventID: ByteArray, + cancelControl: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_EVENT_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_EVENT_I_D_REQ), eventID) + + val TAG_CANCEL_CONTROL_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun clearLoadControlEventsRequest(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Loadcontrolprograms attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + return LoadControlProgramsAttribute(decodedValue) + } + + suspend fun readNumberOfLoadControlProgramsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofloadcontrolprograms attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readEventsAttribute(): EventsAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Events attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + + return EventsAttribute(decodedValue) + } + + suspend fun readActiveEventsAttribute(): ActiveEventsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activeevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + + return ActiveEventsAttribute(decodedValue) + } + + suspend fun readNumberOfEventsPerProgramAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofeventsperprogram attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readNumberOfTransitionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberoftransitions attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readDefaultRandomStartAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Defaultrandomstart attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeDefaultRandomStartAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 6u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readDefaultRandomDurationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Defaultrandomduration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeDefaultRandomDurationAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 7u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DemandResponseLoadControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 150u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt new file mode 100644 index 00000000000000..51e88cc6500974 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt @@ -0,0 +1,461 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) { + class DeviceTypeListAttribute(val value: List) + + class ServerListAttribute(val value: List) + + class ClientListAttribute(val value: List) + + class PartsListAttribute(val value: List) + + class TagListAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Devicetypelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return DeviceTypeListAttribute(decodedValue) + } + + suspend fun readServerListAttribute(): ServerListAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Serverlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return ServerListAttribute(decodedValue) + } + + suspend fun readClientListAttribute(): ClientListAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clientlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return ClientListAttribute(decodedValue) + } + + suspend fun readPartsListAttribute(): PartsListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Partslist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return PartsListAttribute(decodedValue) + } + + suspend fun readTagListAttribute(): TagListAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Taglist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return TagListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DescriptorCluster::class.java.name) + const val CLUSTER_ID: UInt = 29u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt new file mode 100644 index 00000000000000..3adff50b051520 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt @@ -0,0 +1,691 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DeviceEnergyManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PowerAdjustmentCapabilityAttribute( + val value: List? + ) + + class ForecastAttribute(val value: DeviceEnergyManagementClusterForecastStruct?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun powerAdjustRequest(power: Long, duration: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_POWER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_POWER_REQ), power) + + val TAG_DURATION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun cancelPowerAdjustRequest(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun startTimeAdjustRequest(requestedStartTime: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_REQUESTED_START_TIME_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_REQUESTED_START_TIME_REQ), requestedStartTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun pauseRequest(duration: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DURATION_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun resumeRequest(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun modifyForecastRequest( + forecastId: UInt, + slotAdjustments: List, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_FORECAST_ID_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_FORECAST_ID_REQ), forecastId) + + val TAG_SLOT_ADJUSTMENTS_REQ: Int = 1 + tlvWriter.startArray(ContextSpecificTag(TAG_SLOT_ADJUSTMENTS_REQ)) + for (item in slotAdjustments.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun requestConstraintBasedForecast( + constraints: List, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CONSTRAINTS_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_CONSTRAINTS_REQ)) + for (item in constraints.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readESATypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Esatype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readESACanGenerateAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Esacangenerate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readESAStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Esastate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readAbsMinPowerAttribute(): Long { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Absminpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun readAbsMaxPowerAttribute(): Long { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Absmaxpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Poweradjustmentcapability attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PowerAdjustmentCapabilityAttribute(decodedValue) + } + + suspend fun readForecastAttribute(): ForecastAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Forecast attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ForecastAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DeviceEnergyManagementCluster::class.java.name) + const val CLUSTER_ID: UInt = 152u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt new file mode 100644 index 00000000000000..a40ae5c48fbbed --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt @@ -0,0 +1,383 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DiagnosticLogsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class RetrieveLogsResponse( + val status: UByte, + val logContent: ByteArray, + val UTCTimeStamp: ULong?, + val timeSinceBoot: ULong? + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun retrieveLogsRequest( + intent: UByte, + requestedProtocol: UByte, + transferFileDesignator: String?, + timedInvokeTimeoutMs: Int? = null + ): RetrieveLogsResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_INTENT_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_INTENT_REQ), intent) + + val TAG_REQUESTED_PROTOCOL_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_REQUESTED_PROTOCOL_REQ), requestedProtocol) + + val TAG_TRANSFER_FILE_DESIGNATOR_REQ: Int = 2 + transferFileDesignator?.let { + tlvWriter.put(ContextSpecificTag(TAG_TRANSFER_FILE_DESIGNATOR_REQ), transferFileDesignator) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_LOG_CONTENT: Int = 1 + var logContent_decoded: ByteArray? = null + + val TAG_U_T_C_TIME_STAMP: Int = 2 + var UTCTimeStamp_decoded: ULong? = null + + val TAG_TIME_SINCE_BOOT: Int = 3 + var timeSinceBoot_decoded: ULong? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) { + logContent_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) { + UTCTimeStamp_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getULong(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) { + timeSinceBoot_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getULong(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (logContent_decoded == null) { + throw IllegalStateException("logContent not found in TLV") + } + + tlvReader.exitContainer() + + return RetrieveLogsResponse( + status_decoded, + logContent_decoded, + UTCTimeStamp_decoded, + timeSinceBoot_decoded + ) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DiagnosticLogsCluster::class.java.name) + const val CLUSTER_ID: UInt = 50u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt new file mode 100644 index 00000000000000..5684b27e7555f2 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt @@ -0,0 +1,441 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DishwasherAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun reset(alarms: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ALARMS_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun modifyEnabledAlarms(mask: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MASK_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readMaskAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Mask attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readLatchAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Latch attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readStateAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "State attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readSupportedAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DishwasherAlarmCluster::class.java.name) + const val CLUSTER_ID: UInt = 93u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt new file mode 100644 index 00000000000000..8cda015004b3d4 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt @@ -0,0 +1,579 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DishwasherModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) + + class StartUpModeAttribute(val value: UByte?) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeoutMs: Int? = null + ): ChangeToModeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_STATUS_TEXT: Int = 1 + var statusText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeToModeResponse(status_decoded, statusText_decoded) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpModeAttribute(decodedValue) + } + + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DishwasherModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 89u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt new file mode 100644 index 00000000000000..e97463bc6a8eb5 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt @@ -0,0 +1,3647 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DoorLockCluster(private val controller: MatterController, private val endpointId: UShort) { + class GetWeekDayScheduleResponse( + val weekDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val daysMask: UByte?, + val startHour: UByte?, + val startMinute: UByte?, + val endHour: UByte?, + val endMinute: UByte? + ) + + class GetYearDayScheduleResponse( + val yearDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val localStartTime: UInt?, + val localEndTime: UInt? + ) + + class GetHolidayScheduleResponse( + val holidayIndex: UByte, + val status: UByte, + val localStartTime: UInt?, + val localEndTime: UInt?, + val operatingMode: UByte? + ) + + class GetUserResponse( + val userIndex: UShort, + val userName: String?, + val userUniqueID: UInt?, + val userStatus: UByte?, + val userType: UByte?, + val credentialRule: UByte?, + val credentials: List?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, + val nextUserIndex: UShort? + ) + + class SetCredentialResponse( + val status: UByte, + val userIndex: UShort?, + val nextCredentialIndex: UShort? + ) + + class GetCredentialStatusResponse( + val credentialExists: Boolean, + val userIndex: UShort?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, + val nextCredentialIndex: UShort? + ) + + class LockStateAttribute(val value: UByte?) + + class DoorStateAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun lockDoor(PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { + val commandId: UInt = 0u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_P_I_N_CODE_REQ: Int = 0 + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun unlockDoor(PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { + val commandId: UInt = 1u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_P_I_N_CODE_REQ: Int = 0 + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun unlockWithTimeout(timeout: UShort, PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { + val commandId: UInt = 3u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TIMEOUT_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_REQ), timeout) + + val TAG_P_I_N_CODE_REQ: Int = 1 + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + daysMask: UByte, + startHour: UByte, + startMinute: UByte, + endHour: UByte, + endMinute: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 11u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_WEEK_DAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + + val TAG_DAYS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_DAYS_MASK_REQ), daysMask) + + val TAG_START_HOUR_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_START_HOUR_REQ), startHour) + + val TAG_START_MINUTE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_START_MINUTE_REQ), startMinute) + + val TAG_END_HOUR_REQ: Int = 5 + tlvWriter.put(ContextSpecificTag(TAG_END_HOUR_REQ), endHour) + + val TAG_END_MINUTE_REQ: Int = 6 + tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeoutMs: Int? = null + ): GetWeekDayScheduleResponse { + val commandId: UInt = 12u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_WEEK_DAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_WEEK_DAY_INDEX: Int = 0 + var weekDayIndex_decoded: UByte? = null + + val TAG_USER_INDEX: Int = 1 + var userIndex_decoded: UShort? = null + + val TAG_STATUS: Int = 2 + var status_decoded: UByte? = null + + val TAG_DAYS_MASK: Int = 3 + var daysMask_decoded: UByte? = null + + val TAG_START_HOUR: Int = 4 + var startHour_decoded: UByte? = null + + val TAG_START_MINUTE: Int = 5 + var startMinute_decoded: UByte? = null + + val TAG_END_HOUR: Int = 6 + var endHour_decoded: UByte? = null + + val TAG_END_MINUTE: Int = 7 + var endMinute_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) { + weekDayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DAYS_MASK)) { + daysMask_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_START_HOUR)) { + startHour_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_START_MINUTE)) { + startMinute_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_END_HOUR)) { + endHour_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_END_MINUTE)) { + endMinute_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (weekDayIndex_decoded == null) { + throw IllegalStateException("weekDayIndex not found in TLV") + } + + if (userIndex_decoded == null) { + throw IllegalStateException("userIndex not found in TLV") + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return GetWeekDayScheduleResponse( + weekDayIndex_decoded, + userIndex_decoded, + status_decoded, + daysMask_decoded, + startHour_decoded, + startMinute_decoded, + endHour_decoded, + endMinute_decoded + ) + } + + suspend fun clearWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 13u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_WEEK_DAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + localStartTime: UInt, + localEndTime: UInt, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 14u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_YEAR_DAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + + val TAG_LOCAL_START_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_START_TIME_REQ), localStartTime) + + val TAG_LOCAL_END_TIME_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeoutMs: Int? = null + ): GetYearDayScheduleResponse { + val commandId: UInt = 15u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_YEAR_DAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_YEAR_DAY_INDEX: Int = 0 + var yearDayIndex_decoded: UByte? = null + + val TAG_USER_INDEX: Int = 1 + var userIndex_decoded: UShort? = null + + val TAG_STATUS: Int = 2 + var status_decoded: UByte? = null + + val TAG_LOCAL_START_TIME: Int = 3 + var localStartTime_decoded: UInt? = null + + val TAG_LOCAL_END_TIME: Int = 4 + var localEndTime_decoded: UInt? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) { + yearDayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { + localStartTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { + localEndTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUInt(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (yearDayIndex_decoded == null) { + throw IllegalStateException("yearDayIndex not found in TLV") + } + + if (userIndex_decoded == null) { + throw IllegalStateException("userIndex not found in TLV") + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return GetYearDayScheduleResponse( + yearDayIndex_decoded, + userIndex_decoded, + status_decoded, + localStartTime_decoded, + localEndTime_decoded + ) + } + + suspend fun clearYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 16u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_YEAR_DAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setHolidaySchedule( + holidayIndex: UByte, + localStartTime: UInt, + localEndTime: UInt, + operatingMode: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 17u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_HOLIDAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + + val TAG_LOCAL_START_TIME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_START_TIME_REQ), localStartTime) + + val TAG_LOCAL_END_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) + + val TAG_OPERATING_MODE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getHolidaySchedule( + holidayIndex: UByte, + timedInvokeTimeoutMs: Int? = null + ): GetHolidayScheduleResponse { + val commandId: UInt = 18u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_HOLIDAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_HOLIDAY_INDEX: Int = 0 + var holidayIndex_decoded: UByte? = null + + val TAG_STATUS: Int = 1 + var status_decoded: UByte? = null + + val TAG_LOCAL_START_TIME: Int = 2 + var localStartTime_decoded: UInt? = null + + val TAG_LOCAL_END_TIME: Int = 3 + var localEndTime_decoded: UInt? = null + + val TAG_OPERATING_MODE: Int = 4 + var operatingMode_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) { + holidayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { + localStartTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { + localEndTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) { + operatingMode_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (holidayIndex_decoded == null) { + throw IllegalStateException("holidayIndex not found in TLV") + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return GetHolidayScheduleResponse( + holidayIndex_decoded, + status_decoded, + localStartTime_decoded, + localEndTime_decoded, + operatingMode_decoded + ) + } + + suspend fun clearHolidaySchedule(holidayIndex: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 19u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_HOLIDAY_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setUser( + operationType: UByte, + userIndex: UShort, + userName: String?, + userUniqueID: UInt?, + userStatus: UByte?, + userType: UByte?, + credentialRule: UByte?, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 26u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPERATION_TYPE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_OPERATION_TYPE_REQ), operationType) + + val TAG_USER_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + + val TAG_USER_NAME_REQ: Int = 2 + userName?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) } + + val TAG_USER_UNIQUE_I_D_REQ: Int = 3 + userUniqueID?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) } + + val TAG_USER_STATUS_REQ: Int = 4 + userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } + + val TAG_USER_TYPE_REQ: Int = 5 + userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } + + val TAG_CREDENTIAL_RULE_REQ: Int = 6 + credentialRule?.let { + tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_RULE_REQ), credentialRule) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getUser(userIndex: UShort, timedInvokeTimeoutMs: Int? = null): GetUserResponse { + val commandId: UInt = 27u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_USER_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_USER_INDEX: Int = 0 + var userIndex_decoded: UShort? = null + + val TAG_USER_NAME: Int = 1 + var userName_decoded: String? = null + + val TAG_USER_UNIQUE_I_D: Int = 2 + var userUniqueID_decoded: UInt? = null + + val TAG_USER_STATUS: Int = 3 + var userStatus_decoded: UByte? = null + + val TAG_USER_TYPE: Int = 4 + var userType_decoded: UByte? = null + + val TAG_CREDENTIAL_RULE: Int = 5 + var credentialRule_decoded: UByte? = null + + val TAG_CREDENTIALS: Int = 6 + var credentials_decoded: List? = null + + val TAG_CREATOR_FABRIC_INDEX: Int = 7 + var creatorFabricIndex_decoded: UByte? = null + + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 8 + var lastModifiedFabricIndex_decoded: UByte? = null + + val TAG_NEXT_USER_INDEX: Int = 9 + var nextUserIndex_decoded: UShort? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_NAME)) { + userName_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getString(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) { + userUniqueID_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUInt(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_STATUS)) { + userStatus_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_TYPE)) { + userType_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) { + credentialRule_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREDENTIALS)) { + credentials_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { + creatorFabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { + lastModifiedFabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) { + nextUserIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (userIndex_decoded == null) { + throw IllegalStateException("userIndex not found in TLV") + } + + tlvReader.exitContainer() + + return GetUserResponse( + userIndex_decoded, + userName_decoded, + userUniqueID_decoded, + userStatus_decoded, + userType_decoded, + credentialRule_decoded, + credentials_decoded, + creatorFabricIndex_decoded, + lastModifiedFabricIndex_decoded, + nextUserIndex_decoded + ) + } + + suspend fun clearUser(userIndex: UShort, timedInvokeTimeoutMs: Int) { + val commandId: UInt = 29u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_USER_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setCredential( + operationType: UByte, + credential: DoorLockClusterCredentialStruct, + credentialData: ByteArray, + userIndex: UShort?, + userStatus: UByte?, + userType: UByte?, + timedInvokeTimeoutMs: Int + ): SetCredentialResponse { + val commandId: UInt = 34u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPERATION_TYPE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_OPERATION_TYPE_REQ), operationType) + + val TAG_CREDENTIAL_REQ: Int = 1 + credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) + + val TAG_CREDENTIAL_DATA_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_DATA_REQ), credentialData) + + val TAG_USER_INDEX_REQ: Int = 3 + userIndex?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) } + + val TAG_USER_STATUS_REQ: Int = 4 + userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } + + val TAG_USER_TYPE_REQ: Int = 5 + userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_USER_INDEX: Int = 1 + var userIndex_decoded: UShort? = null + + val TAG_NEXT_CREDENTIAL_INDEX: Int = 2 + var nextCredentialIndex_decoded: UShort? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { + nextCredentialIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return SetCredentialResponse(status_decoded, userIndex_decoded, nextCredentialIndex_decoded) + } + + suspend fun getCredentialStatus( + credential: DoorLockClusterCredentialStruct, + timedInvokeTimeoutMs: Int? = null + ): GetCredentialStatusResponse { + val commandId: UInt = 36u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CREDENTIAL_REQ: Int = 0 + credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_CREDENTIAL_EXISTS: Int = 0 + var credentialExists_decoded: Boolean? = null + + val TAG_USER_INDEX: Int = 1 + var userIndex_decoded: UShort? = null + + val TAG_CREATOR_FABRIC_INDEX: Int = 2 + var creatorFabricIndex_decoded: UByte? = null + + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 3 + var lastModifiedFabricIndex_decoded: UByte? = null + + val TAG_NEXT_CREDENTIAL_INDEX: Int = 4 + var nextCredentialIndex_decoded: UShort? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) { + credentialExists_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { + creatorFabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { + lastModifiedFabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { + nextCredentialIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (credentialExists_decoded == null) { + throw IllegalStateException("credentialExists not found in TLV") + } + + tlvReader.exitContainer() + + return GetCredentialStatusResponse( + credentialExists_decoded, + userIndex_decoded, + creatorFabricIndex_decoded, + lastModifiedFabricIndex_decoded, + nextCredentialIndex_decoded + ) + } + + suspend fun clearCredential( + credential: DoorLockClusterCredentialStruct?, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 38u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CREDENTIAL_REQ: Int = 0 + credential?.let { credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun unboltDoor(PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { + val commandId: UInt = 39u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_P_I_N_CODE_REQ: Int = 0 + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readLockStateAttribute(): LockStateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lockstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LockStateAttribute(decodedValue) + } + + suspend fun readLockTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Locktype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readActuatorEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Actuatorenabled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readDoorStateAttribute(): DoorStateAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Doorstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DoorStateAttribute(decodedValue) + } + + suspend fun readDoorOpenEventsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dooropenevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeDoorOpenEventsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readDoorClosedEventsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Doorclosedevents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeDoorClosedEventsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOpenPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Openperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOpenPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 6u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberoftotaluserssupported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofpinuserssupported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofrfiduserssupported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMaxPINCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxpincodelength attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMinPINCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minpincodelength attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMaxRFIDCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxrfidcodelength attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMinRFIDCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minrfidcodelength attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCredentialRulesSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Credentialrulessupport attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLanguageAttribute(): String? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Language attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLanguageAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 33u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLEDSettingsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ledsettings attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLEDSettingsAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 34u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAutoRelockTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Autorelocktime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeAutoRelockTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 35u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSoundVolumeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Soundvolume attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeSoundVolumeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 36u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOperatingModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operatingmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeOperatingModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 37u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSupportedOperatingModesAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedoperatingmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readDefaultConfigurationRegisterAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Defaultconfigurationregister attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readEnableLocalProgrammingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enablelocalprogramming attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeEnableLocalProgrammingAttribute( + value: Boolean, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 40u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnableOneTouchLockingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enableonetouchlocking attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeEnableOneTouchLockingAttribute( + value: Boolean, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 41u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnableInsideStatusLEDAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enableinsidestatusled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeEnableInsideStatusLEDAttribute( + value: Boolean, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 42u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enableprivacymodebutton attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeEnablePrivacyModeButtonAttribute( + value: Boolean, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 43u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLocalProgrammingFeaturesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 44u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Localprogrammingfeatures attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLocalProgrammingFeaturesAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 44u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readWrongCodeEntryLimitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wrongcodeentrylimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeWrongCodeEntryLimitAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 48u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Usercodetemporarydisabletime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUserCodeTemporaryDisableTimeAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 49u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSendPINOverTheAirAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sendpinovertheair attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeSendPINOverTheAirAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 50u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Requirepinforremoteoperation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRequirePINforRemoteOperationAttribute( + value: Boolean, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 51u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readExpiringUserTimeoutAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Expiringusertimeout attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeExpiringUserTimeoutAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 53u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(DoorLockCluster::class.java.name) + const val CLUSTER_ID: UInt = 257u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt new file mode 100644 index 00000000000000..b6712691a6d7cd --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt @@ -0,0 +1,474 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class ElectricalEnergyMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AccuracyAttribute(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) + + class CumulativeEnergyImportedAttribute( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) + + class CumulativeEnergyExportedAttribute( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) + + class PeriodicEnergyImportedAttribute( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) + + class PeriodicEnergyExportedAttribute( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readAccuracyAttribute(): AccuracyAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accuracy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = + ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) + + return AccuracyAttribute(decodedValue) + } + + suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Cumulativeenergyimported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CumulativeEnergyImportedAttribute(decodedValue) + } + + suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Cumulativeenergyexported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CumulativeEnergyExportedAttribute(decodedValue) + } + + suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Periodicenergyimported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeriodicEnergyImportedAttribute(decodedValue) + } + + suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Periodicenergyexported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeriodicEnergyExportedAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ElectricalEnergyMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 145u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt new file mode 100644 index 00000000000000..cff2c16d51397b --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt @@ -0,0 +1,5317 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun getProfileInfoCommand(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getMeasurementProfileCommand( + attributeId: UShort, + startTime: UInt, + numberOfIntervals: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ATTRIBUTE_ID_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ATTRIBUTE_ID_REQ), attributeId) + + val TAG_START_TIME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) + + val TAG_NUMBER_OF_INTERVALS_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readMeasurementTypeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementtype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 256u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcVoltageMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 257u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcvoltagemin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcVoltageMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 258u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcvoltagemax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 259u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcCurrentMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 260u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dccurrentmin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcCurrentMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 261u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dccurrentmax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcPowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 262u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcPowerMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 263u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcpowermin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcPowerMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 264u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcpowermax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcVoltageMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 512u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcvoltagemultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcVoltageDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 513u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcvoltagedivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcCurrentMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 514u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dccurrentmultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcCurrentDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 515u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dccurrentdivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcPowerMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 516u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcpowermultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDcPowerDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 517u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dcpowerdivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 768u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acfrequency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcFrequencyMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 769u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acfrequencymin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcFrequencyMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 770u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acfrequencymax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNeutralCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 771u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Neutralcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTotalActivePowerAttribute(): Int? { + val ATTRIBUTE_ID: UInt = 772u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Totalactivepower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTotalReactivePowerAttribute(): Int? { + val ATTRIBUTE_ID: UInt = 773u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Totalreactivepower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTotalApparentPowerAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 774u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Totalapparentpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 775u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measured1stharmoniccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 776u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measured3rdharmoniccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 777u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measured5thharmoniccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 778u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measured7thharmoniccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 779u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measured9thharmoniccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 780u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measured11thharmoniccurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 781u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 782u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 783u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 784u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 785u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 786u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcFrequencyMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1024u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acfrequencymultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcFrequencyDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1025u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acfrequencydivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPowerMultiplierAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1026u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powermultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPowerDivisorAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1027u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powerdivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1028u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Harmoniccurrentmultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1029u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstantaneousVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1280u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Instantaneousvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstantaneousLineCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1281u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Instantaneouslinecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstantaneousActiveCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1282u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Instantaneousactivecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstantaneousReactiveCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1283u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Instantaneousreactivecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstantaneousPowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1284u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Instantaneouspower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1285u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1286u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1287u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1288u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1289u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentmin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1290u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentmax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1291u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1292u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowermin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1293u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowermax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readReactivePowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1294u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivepower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readApparentPowerAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1295u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Apparentpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPowerFactorAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1296u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powerfactor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1297u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeAverageRmsVoltageMeasurementPeriodAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 1297u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1299u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeAverageRmsUnderVoltageCounterAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 1299u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1300u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsextremeovervoltageperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRmsExtremeOverVoltagePeriodAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 1300u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1301u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsextremeundervoltageperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRmsExtremeUnderVoltagePeriodAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 1301u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRmsVoltageSagPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1302u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRmsVoltageSagPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1302u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1303u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiod attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRmsVoltageSwellPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1303u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAcVoltageMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1536u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acvoltagemultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcVoltageDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1537u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acvoltagedivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcCurrentMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1538u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accurrentmultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcCurrentDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1539u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accurrentdivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcPowerMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1540u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acpowermultiplier attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcPowerDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1541u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acpowerdivisor attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readOverloadAlarmsMaskAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1792u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Overloadalarmsmask attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOverloadAlarmsMaskAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1792u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readVoltageOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1793u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Voltageoverload attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1794u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentoverload attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2048u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acoverloadalarmsmask attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeAcOverloadAlarmsMaskAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2048u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAcVoltageOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2049u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acvoltageoverload attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcCurrentOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2050u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accurrentoverload attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcActivePowerOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2051u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acactivepoweroverload attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAcReactivePowerOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2052u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acreactivepoweroverload attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsOverVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2053u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagermsovervoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsUnderVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2054u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagermsundervoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsExtremeOverVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2055u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsextremeovervoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsExtremeUnderVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2056u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsextremeundervoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageSagAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2057u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageSwellAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2058u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltageswell attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLineCurrentPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2305u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Linecurrentphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActiveCurrentPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2306u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activecurrentphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readReactiveCurrentPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2307u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivecurrentphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltagePhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2309u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagephaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2310u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltageminphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2311u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagemaxphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2312u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2313u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentminphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2314u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentmaxphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2315u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowerphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerMinPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2316u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowerminphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerMaxPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2317u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowermaxphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readReactivePowerPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2318u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivepowerphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readApparentPowerPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2319u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Apparentpowerphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPowerFactorPhaseBAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 2320u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powerfactorphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2321u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2322u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2323u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2324u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2325u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2326u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiodphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2327u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiodphaseb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLineCurrentPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2561u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Linecurrentphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActiveCurrentPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2562u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activecurrentphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readReactiveCurrentPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2563u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivecurrentphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltagePhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2565u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagephasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2566u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltageminphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2567u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagemaxphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2568u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2569u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentminphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2570u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmscurrentmaxphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2571u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowerphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerMinPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2572u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowerminphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActivePowerMaxPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2573u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activepowermaxphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readReactivePowerPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2574u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Reactivepowerphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readApparentPowerPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2575u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Apparentpowerphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPowerFactorPhaseCAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 2576u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powerfactorphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2577u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2578u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2579u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2580u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2581u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2582u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiodphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2583u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiodphasec attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ElectricalMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 2820u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt new file mode 100644 index 00000000000000..231bed8970f88a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt @@ -0,0 +1,1563 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class EnergyEvseCluster(private val controller: MatterController, private val endpointId: UShort) { + class GetTargetsResponse( + val dayOfWeekforSequence: UByte, + val chargingTargets: List + ) + + class StateAttribute(val value: UByte?) + + class ChargingEnabledUntilAttribute(val value: UInt?) + + class DischargingEnabledUntilAttribute(val value: UInt?) + + class NextChargeStartTimeAttribute(val value: UInt?) + + class NextChargeTargetTimeAttribute(val value: UInt?) + + class NextChargeRequiredEnergyAttribute(val value: Long?) + + class NextChargeTargetSoCAttribute(val value: UByte?) + + class ApproximateEVEfficiencyAttribute(val value: UShort?) + + class StateOfChargeAttribute(val value: UByte?) + + class BatteryCapacityAttribute(val value: Long?) + + class VehicleIDAttribute(val value: String?) + + class SessionIDAttribute(val value: UInt?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun disable(timedInvokeTimeoutMs: Int) { + val commandId: UInt = 1u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enableCharging( + chargingEnabledUntil: UInt?, + minimumChargeCurrent: Long, + maximumChargeCurrent: Long, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CHARGING_ENABLED_UNTIL_REQ: Int = 0 + chargingEnabledUntil?.let { + tlvWriter.put(ContextSpecificTag(TAG_CHARGING_ENABLED_UNTIL_REQ), chargingEnabledUntil) + } + + val TAG_MINIMUM_CHARGE_CURRENT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_MINIMUM_CHARGE_CURRENT_REQ), minimumChargeCurrent) + + val TAG_MAXIMUM_CHARGE_CURRENT_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun enableDischarging( + dischargingEnabledUntil: UInt?, + maximumDischargeCurrent: Long, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 3u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DISCHARGING_ENABLED_UNTIL_REQ: Int = 0 + dischargingEnabledUntil?.let { + tlvWriter.put(ContextSpecificTag(TAG_DISCHARGING_ENABLED_UNTIL_REQ), dischargingEnabledUntil) + } + + val TAG_MAXIMUM_DISCHARGE_CURRENT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun startDiagnostics(timedInvokeTimeoutMs: Int) { + val commandId: UInt = 4u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setTargets( + dayOfWeekforSequence: UByte, + chargingTargets: List, + timedInvokeTimeoutMs: Int + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DAY_OF_WEEKFOR_SEQUENCE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE_REQ), dayOfWeekforSequence) + + val TAG_CHARGING_TARGETS_REQ: Int = 1 + tlvWriter.startArray(ContextSpecificTag(TAG_CHARGING_TARGETS_REQ)) + for (item in chargingTargets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getTargets(daysToReturn: UByte, timedInvokeTimeoutMs: Int): GetTargetsResponse { + val commandId: UInt = 6u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DAYS_TO_RETURN_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_DAYS_TO_RETURN_REQ), daysToReturn) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_DAY_OF_WEEKFOR_SEQUENCE: Int = 0 + var dayOfWeekforSequence_decoded: UByte? = null + + val TAG_CHARGING_TARGETS: Int = 1 + var chargingTargets_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE)) { + dayOfWeekforSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_CHARGING_TARGETS)) { + chargingTargets_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (dayOfWeekforSequence_decoded == null) { + throw IllegalStateException("dayOfWeekforSequence not found in TLV") + } + + if (chargingTargets_decoded == null) { + throw IllegalStateException("chargingTargets not found in TLV") + } + + tlvReader.exitContainer() + + return GetTargetsResponse(dayOfWeekforSequence_decoded, chargingTargets_decoded) + } + + suspend fun clearTargets(timedInvokeTimeoutMs: Int) { + val commandId: UInt = 7u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readStateAttribute(): StateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "State attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StateAttribute(decodedValue) + } + + suspend fun readSupplyStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supplystate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readFaultStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Faultstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Chargingenableduntil attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ChargingEnabledUntilAttribute(decodedValue) + } + + suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dischargingenableduntil attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DischargingEnabledUntilAttribute(decodedValue) + } + + suspend fun readCircuitCapacityAttribute(): Long { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Circuitcapacity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun readMinimumChargeCurrentAttribute(): Long { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minimumchargecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun readMaximumChargeCurrentAttribute(): Long { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maximumchargecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun readMaximumDischargeCurrentAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maximumdischargecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUserMaximumChargeCurrentAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Usermaximumchargecurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUserMaximumChargeCurrentAttribute( + value: Long, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 9u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRandomizationDelayWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Randomizationdelaywindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRandomizationDelayWindowAttribute( + value: UInt, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 10u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNumberOfWeeklyTargetsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofweeklytargets attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfDailyTargetsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofdailytargets attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nextchargestarttime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NextChargeStartTimeAttribute(decodedValue) + } + + suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nextchargetargettime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NextChargeTargetTimeAttribute(decodedValue) + } + + suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nextchargerequiredenergy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NextChargeRequiredEnergyAttribute(decodedValue) + } + + suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nextchargetargetsoc attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NextChargeTargetSoCAttribute(decodedValue) + } + + suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Approximateevefficiency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ApproximateEVEfficiencyAttribute(decodedValue) + } + + suspend fun writeApproximateEVEfficiencyAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 39u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Stateofcharge attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StateOfChargeAttribute(decodedValue) + } + + suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batterycapacity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BatteryCapacityAttribute(decodedValue) + } + + suspend fun readVehicleIDAttribute(): VehicleIDAttribute { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vehicleid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return VehicleIDAttribute(decodedValue) + } + + suspend fun readSessionIDAttribute(): SessionIDAttribute { + val ATTRIBUTE_ID: UInt = 64u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sessionid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SessionIDAttribute(decodedValue) + } + + suspend fun readSessionDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sessionduration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readSessionEnergyChargedAttribute(): Long { + val ATTRIBUTE_ID: UInt = 66u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sessionenergycharged attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun readSessionEnergyDischargedAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 67u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sessionenergydischarged attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(EnergyEvseCluster::class.java.name) + const val CLUSTER_ID: UInt = 153u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt new file mode 100644 index 00000000000000..fcbff87fd95e32 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt @@ -0,0 +1,630 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class EthernetNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PHYRateAttribute(val value: UByte?) + + class FullDuplexAttribute(val value: Boolean?) + + class CarrierDetectAttribute(val value: Boolean?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun resetCounts(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readPHYRateAttribute(): PHYRateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Phyrate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PHYRateAttribute(decodedValue) + } + + suspend fun readFullDuplexAttribute(): FullDuplexAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Fullduplex attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return FullDuplexAttribute(decodedValue) + } + + suspend fun readPacketRxCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Packetrxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPacketTxCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Packettxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxErrCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txerrcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCollisionCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Collisioncount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readOverrunCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Carrierdetect attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CarrierDetectAttribute(decodedValue) + } + + suspend fun readTimeSinceResetAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timesincereset attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(EthernetNetworkDiagnosticsCluster::class.java.name) + const val CLUSTER_ID: UInt = 55u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt new file mode 100644 index 00000000000000..a2be5a8f645b37 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt @@ -0,0 +1,979 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) { + class PercentSettingAttribute(val value: UByte?) + + class SpeedSettingAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun step( + direction: UByte, + wrap: Boolean?, + lowestOff: Boolean?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DIRECTION_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) + + val TAG_WRAP_REQ: Int = 1 + wrap?.let { tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) } + + val TAG_LOWEST_OFF_REQ: Int = 2 + lowestOff?.let { tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readFanModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Fanmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeFanModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readFanModeSequenceAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Fanmodesequence attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readPercentSettingAttribute(): PercentSettingAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Percentsetting attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PercentSettingAttribute(decodedValue) + } + + suspend fun writePercentSettingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPercentCurrentAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Percentcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readSpeedMaxAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Speedmax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Speedsetting attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SpeedSettingAttribute(decodedValue) + } + + suspend fun writeSpeedSettingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSpeedCurrentAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Speedcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRockSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rocksupport attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRockSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rocksetting attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRockSettingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 8u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readWindSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Windsupport attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readWindSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Windsetting attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeWindSettingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 10u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAirflowDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Airflowdirection attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeAirflowDirectionAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 11u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(FanControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 514u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt new file mode 100644 index 00000000000000..e765024b458f3a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt @@ -0,0 +1,342 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class FaultInjectionCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun failAtFault( + type: UByte, + id: UInt, + numCallsToSkip: UInt, + numCallsToFail: UInt, + takeMutex: Boolean, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TYPE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TYPE_REQ), type) + + val TAG_ID_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ID_REQ), id) + + val TAG_NUM_CALLS_TO_SKIP_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_NUM_CALLS_TO_SKIP_REQ), numCallsToSkip) + + val TAG_NUM_CALLS_TO_FAIL_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_NUM_CALLS_TO_FAIL_REQ), numCallsToFail) + + val TAG_TAKE_MUTEX_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun failRandomlyAtFault( + type: UByte, + id: UInt, + percentage: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TYPE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TYPE_REQ), type) + + val TAG_ID_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ID_REQ), id) + + val TAG_PERCENTAGE_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(FaultInjectionCluster::class.java.name) + const val CLUSTER_ID: UInt = 4294048774u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt new file mode 100644 index 00000000000000..6d6c8098a99767 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt @@ -0,0 +1,297 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) { + class LabelListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readLabelListAttribute(): LabelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Labellist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return LabelListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(FixedLabelCluster::class.java.name) + const val CLUSTER_ID: UInt = 64u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt new file mode 100644 index 00000000000000..0f9c139f6dcd6e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt @@ -0,0 +1,413 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class FlowMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) + + class MinMeasuredValueAttribute(val value: UShort?) + + class MaxMeasuredValueAttribute(val value: UShort?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(FlowMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1028u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..ddcc4dedd812b7 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt @@ -0,0 +1,692 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class FormaldehydeConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1067u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt new file mode 100644 index 00000000000000..ea455c635b4075 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt @@ -0,0 +1,668 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class GeneralCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ArmFailSafeResponse(val errorCode: UByte, val debugText: String) + + class SetRegulatoryConfigResponse(val errorCode: UByte, val debugText: String) + + class CommissioningCompleteResponse(val errorCode: UByte, val debugText: String) + + class BasicCommissioningInfoAttribute( + val value: GeneralCommissioningClusterBasicCommissioningInfo + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun armFailSafe( + expiryLengthSeconds: UShort, + breadcrumb: ULong, + timedInvokeTimeoutMs: Int? = null + ): ArmFailSafeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_EXPIRY_LENGTH_SECONDS_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_EXPIRY_LENGTH_SECONDS_REQ), expiryLengthSeconds) + + val TAG_BREADCRUMB_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ERROR_CODE: Int = 0 + var errorCode_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (errorCode_decoded == null) { + throw IllegalStateException("errorCode not found in TLV") + } + + if (debugText_decoded == null) { + throw IllegalStateException("debugText not found in TLV") + } + + tlvReader.exitContainer() + + return ArmFailSafeResponse(errorCode_decoded, debugText_decoded) + } + + suspend fun setRegulatoryConfig( + newRegulatoryConfig: UByte, + countryCode: String, + breadcrumb: ULong, + timedInvokeTimeoutMs: Int? = null + ): SetRegulatoryConfigResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_REGULATORY_CONFIG_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_REGULATORY_CONFIG_REQ), newRegulatoryConfig) + + val TAG_COUNTRY_CODE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_COUNTRY_CODE_REQ), countryCode) + + val TAG_BREADCRUMB_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ERROR_CODE: Int = 0 + var errorCode_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (errorCode_decoded == null) { + throw IllegalStateException("errorCode not found in TLV") + } + + if (debugText_decoded == null) { + throw IllegalStateException("debugText not found in TLV") + } + + tlvReader.exitContainer() + + return SetRegulatoryConfigResponse(errorCode_decoded, debugText_decoded) + } + + suspend fun commissioningComplete( + timedInvokeTimeoutMs: Int? = null + ): CommissioningCompleteResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ERROR_CODE: Int = 0 + var errorCode_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (errorCode_decoded == null) { + throw IllegalStateException("errorCode not found in TLV") + } + + if (debugText_decoded == null) { + throw IllegalStateException("debugText not found in TLV") + } + + tlvReader.exitContainer() + + return CommissioningCompleteResponse(errorCode_decoded, debugText_decoded) + } + + suspend fun readBreadcrumbAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Breadcrumb attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeBreadcrumbAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Basiccommissioninginfo attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = + GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) + + return BasicCommissioningInfoAttribute(decodedValue) + } + + suspend fun readRegulatoryConfigAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Regulatoryconfig attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readLocationCapabilityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Locationcapability attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readSupportsConcurrentConnectionAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportsconcurrentconnection attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(GeneralCommissioningCluster::class.java.name) + const val CLUSTER_ID: UInt = 48u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt new file mode 100644 index 00000000000000..247fd54f345036 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt @@ -0,0 +1,702 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class GeneralDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class TimeSnapshotResponse(val systemTimeUs: ULong, val UTCTimeUs: ULong?) + + class NetworkInterfacesAttribute(val value: List) + + class ActiveHardwareFaultsAttribute(val value: List?) + + class ActiveRadioFaultsAttribute(val value: List?) + + class ActiveNetworkFaultsAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun testEventTrigger( + enableKey: ByteArray, + eventTrigger: ULong, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ENABLE_KEY_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ENABLE_KEY_REQ), enableKey) + + val TAG_EVENT_TRIGGER_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun timeSnapshot(timedInvokeTimeoutMs: Int? = null): TimeSnapshotResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_SYSTEM_TIME_US: Int = 0 + var systemTimeUs_decoded: ULong? = null + + val TAG_U_T_C_TIME_US: Int = 1 + var UTCTimeUs_decoded: ULong? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_US)) { + systemTimeUs_decoded = tlvReader.getULong(tag) + } + + if (tag == ContextSpecificTag(TAG_U_T_C_TIME_US)) { + UTCTimeUs_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getULong(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (systemTimeUs_decoded == null) { + throw IllegalStateException("systemTimeUs not found in TLV") + } + + tlvReader.exitContainer() + + return TimeSnapshotResponse(systemTimeUs_decoded, UTCTimeUs_decoded) + } + + suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Networkinterfaces attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return NetworkInterfacesAttribute(decodedValue) + } + + suspend fun readRebootCountAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rebootcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readUpTimeAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uptime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTotalOperationalHoursAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Totaloperationalhours attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBootReasonAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Bootreason attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activehardwarefaults attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveHardwareFaultsAttribute(decodedValue) + } + + suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activeradiofaults attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveRadioFaultsAttribute(decodedValue) + } + + suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activenetworkfaults attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveNetworkFaultsAttribute(decodedValue) + } + + suspend fun readTestEventTriggersEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Testeventtriggersenabled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(GeneralDiagnosticsCluster::class.java.name) + const val CLUSTER_ID: UInt = 51u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt new file mode 100644 index 00000000000000..00e415940a8d10 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt @@ -0,0 +1,616 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class GroupKeyManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class KeySetReadResponse(val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct) + + class KeySetReadAllIndicesResponse(val groupKeySetIDs: List) + + class GroupKeyMapAttribute(val value: List) + + class GroupTableAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun keySetWrite( + groupKeySet: GroupKeyManagementClusterGroupKeySetStruct, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_KEY_SET_REQ: Int = 0 + groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun keySetRead( + groupKeySetID: UShort, + timedInvokeTimeoutMs: Int? = null + ): KeySetReadResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_GROUP_KEY_SET: Int = 0 + var groupKeySet_decoded: GroupKeyManagementClusterGroupKeySetStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) { + groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (groupKeySet_decoded == null) { + throw IllegalStateException("groupKeySet not found in TLV") + } + + tlvReader.exitContainer() + + return KeySetReadResponse(groupKeySet_decoded) + } + + suspend fun keySetRemove(groupKeySetID: UShort, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun keySetReadAllIndices( + timedInvokeTimeoutMs: Int? = null + ): KeySetReadAllIndicesResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_GROUP_KEY_SET_I_DS: Int = 0 + var groupKeySetIDs_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) { + groupKeySetIDs_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (groupKeySetIDs_decoded == null) { + throw IllegalStateException("groupKeySetIDs not found in TLV") + } + + tlvReader.exitContainer() + + return KeySetReadAllIndicesResponse(groupKeySetIDs_decoded) + } + + suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Groupkeymap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return GroupKeyMapAttribute(decodedValue) + } + + suspend fun writeGroupKeyMapAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGroupTableAttribute(): GroupTableAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Grouptable attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return GroupTableAttribute(decodedValue) + } + + suspend fun readMaxGroupsPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxgroupsperfabric attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readMaxGroupKeysPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxgroupkeysperfabric attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(GroupKeyManagementCluster::class.java.name) + const val CLUSTER_ID: UInt = 63u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt new file mode 100644 index 00000000000000..a1c38ca8e8e0d2 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt @@ -0,0 +1,623 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class GroupsCluster(private val controller: MatterController, private val endpointId: UShort) { + class AddGroupResponse(val status: UByte, val groupID: UShort) + + class ViewGroupResponse(val status: UByte, val groupID: UShort, val groupName: String) + + class GetGroupMembershipResponse(val capacity: UByte?, val groupList: List) + + class RemoveGroupResponse(val status: UByte, val groupID: UShort) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun addGroup( + groupID: UShort, + groupName: String, + timedInvokeTimeoutMs: Int? = null + ): AddGroupResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_GROUP_NAME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + tlvReader.exitContainer() + + return AddGroupResponse(status_decoded, groupID_decoded) + } + + suspend fun viewGroup(groupID: UShort, timedInvokeTimeoutMs: Int? = null): ViewGroupResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_GROUP_NAME: Int = 2 + var groupName_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_NAME)) { + groupName_decoded = tlvReader.getString(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (groupName_decoded == null) { + throw IllegalStateException("groupName not found in TLV") + } + + tlvReader.exitContainer() + + return ViewGroupResponse(status_decoded, groupID_decoded, groupName_decoded) + } + + suspend fun getGroupMembership( + groupList: List, + timedInvokeTimeoutMs: Int? = null + ): GetGroupMembershipResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_LIST_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_GROUP_LIST_REQ)) + for (item in groupList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_CAPACITY: Int = 0 + var capacity_decoded: UByte? = null + + val TAG_GROUP_LIST: Int = 1 + var groupList_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_CAPACITY)) { + capacity_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_GROUP_LIST)) { + groupList_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (groupList_decoded == null) { + throw IllegalStateException("groupList not found in TLV") + } + + tlvReader.exitContainer() + + return GetGroupMembershipResponse(capacity_decoded, groupList_decoded) + } + + suspend fun removeGroup(groupID: UShort, timedInvokeTimeoutMs: Int? = null): RemoveGroupResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + tlvReader.exitContainer() + + return RemoveGroupResponse(status_decoded, groupID_decoded) + } + + suspend fun removeAllGroups(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun addGroupIfIdentifying( + groupID: UShort, + groupName: String, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_GROUP_NAME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readNameSupportAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Namesupport attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(GroupsCluster::class.java.name) + const val CLUSTER_ID: UInt = 4u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt new file mode 100644 index 00000000000000..330aba9b6213c8 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt @@ -0,0 +1,560 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class HepaFilterMonitoringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LastChangedTimeAttribute(val value: UInt?) + + class ReplacementProductListAttribute( + val value: List? + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun resetCondition(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readConditionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Condition attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDegradationDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readChangeIndicationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Changeindication attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readInPlaceIndicatorAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LastChangedTimeAttribute(decodedValue) + } + + suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ReplacementProductListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(HepaFilterMonitoringCluster::class.java.name) + const val CLUSTER_ID: UInt = 113u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt new file mode 100644 index 00000000000000..029dd194007c31 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt @@ -0,0 +1,695 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class IcdManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class RegisterClientResponse(val ICDCounter: UInt) + + class StayActiveResponse(val promisedActiveDuration: UInt) + + class RegisteredClientsAttribute( + val value: List? + ) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun registerClient( + checkInNodeID: ULong, + monitoredSubject: ULong, + key: ByteArray, + verificationKey: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): RegisterClientResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CHECK_IN_NODE_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D_REQ), checkInNodeID) + + val TAG_MONITORED_SUBJECT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_MONITORED_SUBJECT_REQ), monitoredSubject) + + val TAG_KEY_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_KEY_REQ), key) + + val TAG_VERIFICATION_KEY_REQ: Int = 3 + verificationKey?.let { + tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_I_C_D_COUNTER: Int = 0 + var ICDCounter_decoded: UInt? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) { + ICDCounter_decoded = tlvReader.getUInt(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (ICDCounter_decoded == null) { + throw IllegalStateException("ICDCounter not found in TLV") + } + + tlvReader.exitContainer() + + return RegisterClientResponse(ICDCounter_decoded) + } + + suspend fun unregisterClient( + checkInNodeID: ULong, + verificationKey: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CHECK_IN_NODE_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D_REQ), checkInNodeID) + + val TAG_VERIFICATION_KEY_REQ: Int = 1 + verificationKey?.let { + tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stayActiveRequest(timedInvokeTimeoutMs: Int? = null): StayActiveResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_PROMISED_ACTIVE_DURATION: Int = 0 + var promisedActiveDuration_decoded: UInt? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) { + promisedActiveDuration_decoded = tlvReader.getUInt(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (promisedActiveDuration_decoded == null) { + throw IllegalStateException("promisedActiveDuration not found in TLV") + } + + tlvReader.exitContainer() + + return StayActiveResponse(promisedActiveDuration_decoded) + } + + suspend fun readIdleModeDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Idlemodeduration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readActiveModeDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activemodeduration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readActiveModeThresholdAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activemodethreshold attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Registeredclients attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return RegisteredClientsAttribute(decodedValue) + } + + suspend fun readICDCounterAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Icdcounter attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readClientsSupportedPerFabricAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clientssupportedperfabric attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUserActiveModeTriggerHintAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Useractivemodetriggerhint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUserActiveModeTriggerInstructionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(IcdManagementCluster::class.java.name) + const val CLUSTER_ID: UInt = 70u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt new file mode 100644 index 00000000000000..2cffe72cefd399 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt @@ -0,0 +1,423 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun identify(identifyTime: UShort, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_IDENTIFY_TIME_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun triggerEffect( + effectIdentifier: UByte, + effectVariant: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 64u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_EFFECT_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) + + val TAG_EFFECT_VARIANT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readIdentifyTimeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Identifytime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeIdentifyTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readIdentifyTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Identifytype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(IdentifyCluster::class.java.name) + const val CLUSTER_ID: UInt = 3u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt new file mode 100644 index 00000000000000..df1c954e98f276 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt @@ -0,0 +1,456 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class IlluminanceMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) + + class MinMeasuredValueAttribute(val value: UShort?) + + class MaxMeasuredValueAttribute(val value: UShort?) + + class LightSensorTypeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lightsensortype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LightSensorTypeAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(IlluminanceMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1024u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt new file mode 100644 index 00000000000000..dc18411b24044b --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt @@ -0,0 +1,312 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class KeypadInputCluster(private val controller: MatterController, private val endpointId: UShort) { + class SendKeyResponse(val status: UByte) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun sendKey(keyCode: UByte, timedInvokeTimeoutMs: Int? = null): SendKeyResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_KEY_CODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return SendKeyResponse(status_decoded) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(KeypadInputCluster::class.java.name) + const val CLUSTER_ID: UInt = 1289u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt new file mode 100644 index 00000000000000..e840eaa128b766 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt @@ -0,0 +1,386 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class LaundryDryerControlsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedDrynessLevelsAttribute(val value: List) + + class SelectedDrynessLevelAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supporteddrynesslevels attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return SupportedDrynessLevelsAttribute(decodedValue) + } + + suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Selecteddrynesslevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SelectedDrynessLevelAttribute(decodedValue) + } + + suspend fun writeSelectedDrynessLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(LaundryDryerControlsCluster::class.java.name) + const val CLUSTER_ID: UInt = 74u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt new file mode 100644 index 00000000000000..9540e0bcaa8d1b --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt @@ -0,0 +1,516 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class LaundryWasherControlsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SpinSpeedsAttribute(val value: List?) + + class SpinSpeedCurrentAttribute(val value: UByte?) + + class SupportedRinsesAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Spinspeeds attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return SpinSpeedsAttribute(decodedValue) + } + + suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Spinspeedcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SpinSpeedCurrentAttribute(decodedValue) + } + + suspend fun writeSpinSpeedCurrentAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNumberOfRinsesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofrinses attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeNumberOfRinsesAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedrinses attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return SupportedRinsesAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(LaundryWasherControlsCluster::class.java.name) + const val CLUSTER_ID: UInt = 83u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt new file mode 100644 index 00000000000000..4c32d50f224995 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt @@ -0,0 +1,579 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class LaundryWasherModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) + + class StartUpModeAttribute(val value: UByte?) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeoutMs: Int? = null + ): ChangeToModeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_STATUS_TEXT: Int = 1 + var statusText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeToModeResponse(status_decoded, statusText_decoded) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpModeAttribute(decodedValue) + } + + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(LaundryWasherModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 81u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt new file mode 100644 index 00000000000000..8718ed743ba3a3 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt @@ -0,0 +1,1419 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class LevelControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CurrentLevelAttribute(val value: UByte?) + + class OnLevelAttribute(val value: UByte?) + + class OnTransitionTimeAttribute(val value: UShort?) + + class OffTransitionTimeAttribute(val value: UShort?) + + class DefaultMoveRateAttribute(val value: UByte?) + + class StartUpCurrentLevelAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun moveToLevel( + level: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LEVEL_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LEVEL_REQ), level) + + val TAG_TRANSITION_TIME_REQ: Int = 1 + transitionTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + } + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun move( + moveMode: UByte, + rate: UByte?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MOVE_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) + + val TAG_RATE_REQ: Int = 1 + rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun step( + stepMode: UByte, + stepSize: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_MODE_REQ), stepMode) + + val TAG_STEP_SIZE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_SIZE_REQ), stepSize) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + transitionTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + } + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stop(optionsMask: UByte, optionsOverride: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPTIONS_MASK_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveToLevelWithOnOff( + level: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LEVEL_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LEVEL_REQ), level) + + val TAG_TRANSITION_TIME_REQ: Int = 1 + transitionTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + } + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveWithOnOff( + moveMode: UByte, + rate: UByte?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MOVE_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) + + val TAG_RATE_REQ: Int = 1 + rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } + + val TAG_OPTIONS_MASK_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stepWithOnOff( + stepMode: UByte, + stepSize: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_STEP_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_STEP_MODE_REQ), stepMode) + + val TAG_STEP_SIZE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_STEP_SIZE_REQ), stepSize) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + transitionTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + } + + val TAG_OPTIONS_MASK_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stopWithOnOff( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPTIONS_MASK_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) + + val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun moveToClosestFrequency(frequency: UShort, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_FREQUENCY_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentLevelAttribute(decodedValue) + } + + suspend fun readRemainingTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Remainingtime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMinLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMaxLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentfrequency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMinFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minfrequency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMaxFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxfrequency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readOptionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Options attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 15u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnOffTransitionTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onofftransitiontime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOnOffTransitionTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnLevelAttribute(): OnLevelAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnLevelAttribute(decodedValue) + } + + suspend fun writeOnLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 17u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ontransitiontime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnTransitionTimeAttribute(decodedValue) + } + + suspend fun writeOnTransitionTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 18u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Offtransitiontime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OffTransitionTimeAttribute(decodedValue) + } + + suspend fun writeOffTransitionTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 19u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Defaultmoverate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DefaultMoveRateAttribute(decodedValue) + } + + suspend fun writeDefaultMoveRateAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 20u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupcurrentlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpCurrentLevelAttribute(decodedValue) + } + + suspend fun writeStartUpCurrentLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16384u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(LevelControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 8u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt new file mode 100644 index 00000000000000..25259a5b6d033e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt @@ -0,0 +1,378 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class LocalizationConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedLocalesAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readActiveLocaleAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activelocale attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun writeActiveLocaleAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedlocales attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return SupportedLocalesAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(LocalizationConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 43u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt new file mode 100644 index 00000000000000..4cd658b6ecf7b2 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt @@ -0,0 +1,282 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun sleep(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(LowPowerCluster::class.java.name) + const val CLUSTER_ID: UInt = 1288u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt new file mode 100644 index 00000000000000..9294f209f59338 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt @@ -0,0 +1,423 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) { + class InputListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun selectInput(index: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun showInputStatus(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun hideInputStatus(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun renameInput(index: UByte, name: String, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + + val TAG_NAME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readInputListAttribute(): InputListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Inputlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return InputListAttribute(decodedValue) + } + + suspend fun readCurrentInputAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentinput attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(MediaInputCluster::class.java.name) + const val CLUSTER_ID: UInt = 1287u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt new file mode 100644 index 00000000000000..2185773712e036 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt @@ -0,0 +1,1515 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class MediaPlaybackCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PlaybackResponse(val status: UByte, val data: String?) + + class StartTimeAttribute(val value: ULong?) + + class DurationAttribute(val value: ULong?) + + class SampledPositionAttribute(val value: MediaPlaybackClusterPlaybackPositionStruct?) + + class SeekRangeEndAttribute(val value: ULong?) + + class SeekRangeStartAttribute(val value: ULong?) + + class ActiveAudioTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) + + class AvailableAudioTracksAttribute(val value: List?) + + class ActiveTextTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) + + class AvailableTextTracksAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun play(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun pause(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun stop(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun startOver(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun previous(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun next(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun rewind( + audioAdvanceUnmuted: Boolean?, + timedInvokeTimeoutMs: Int? = null + ): PlaybackResponse { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 + audioAdvanceUnmuted?.let { + tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun fastForward( + audioAdvanceUnmuted: Boolean?, + timedInvokeTimeoutMs: Int? = null + ): PlaybackResponse { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 + audioAdvanceUnmuted?.let { + tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun skipForward( + deltaPositionMilliseconds: ULong, + timedInvokeTimeoutMs: Int? = null + ): PlaybackResponse { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 + tlvWriter.put( + ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), + deltaPositionMilliseconds + ) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun skipBackward( + deltaPositionMilliseconds: ULong, + timedInvokeTimeoutMs: Int? = null + ): PlaybackResponse { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 + tlvWriter.put( + ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), + deltaPositionMilliseconds + ) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun seek(position: ULong, timedInvokeTimeoutMs: Int? = null): PlaybackResponse { + val commandId: UInt = 11u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_POSITION_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return PlaybackResponse(status_decoded, data_decoded) + } + + suspend fun activateAudioTrack( + trackID: String, + audioOutputIndex: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 12u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TRACK_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) + + val TAG_AUDIO_OUTPUT_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun activateTextTrack(trackID: String, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 13u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TRACK_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun deactivateTextTrack(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 14u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readCurrentStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readStartTimeAttribute(): StartTimeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Starttime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartTimeAttribute(decodedValue) + } + + suspend fun readDurationAttribute(): DurationAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Duration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DurationAttribute(decodedValue) + } + + suspend fun readSampledPositionAttribute(): SampledPositionAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sampledposition attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SampledPositionAttribute(decodedValue) + } + + suspend fun readPlaybackSpeedAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Playbackspeed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Seekrangeend attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SeekRangeEndAttribute(decodedValue) + } + + suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Seekrangestart attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SeekRangeStartAttribute(decodedValue) + } + + suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activeaudiotrack attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ActiveAudioTrackAttribute(decodedValue) + } + + suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Availableaudiotracks attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AvailableAudioTracksAttribute(decodedValue) + } + + suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activetexttrack attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ActiveTextTrackAttribute(decodedValue) + } + + suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Availabletexttracks attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AvailableTextTracksAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(MediaPlaybackCluster::class.java.name) + const val CLUSTER_ID: UInt = 1286u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt new file mode 100644 index 00000000000000..606bc9dc502b6e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt @@ -0,0 +1,493 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class MicrowaveOvenControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun setCookingParameters( + cookMode: UByte?, + cookTime: UInt?, + powerSetting: UByte?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_COOK_MODE_REQ: Int = 0 + cookMode?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) } + + val TAG_COOK_TIME_REQ: Int = 1 + cookTime?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) } + + val TAG_POWER_SETTING_REQ: Int = 2 + powerSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun addMoreTime(timeToAdd: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TIME_TO_ADD_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readCookTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Cooktime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readPowerSettingAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powersetting attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readMinPowerAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMaxPowerAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxpower attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPowerStepAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Powerstep attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(MicrowaveOvenControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 95u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt new file mode 100644 index 00000000000000..77196e06d86eba --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt @@ -0,0 +1,331 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class MicrowaveOvenModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedModesAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(MicrowaveOvenModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 94u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt new file mode 100644 index 00000000000000..6231d0fda5f8b7 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt @@ -0,0 +1,600 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) { + class StandardNamespaceAttribute(val value: UShort?) + + class SupportedModesAttribute(val value: List) + + class StartUpModeAttribute(val value: UByte?) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode(newMode: UByte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readDescriptionAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Description attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Standardnamespace attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StandardNamespaceAttribute(decodedValue) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpModeAttribute(decodedValue) + } + + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ModeSelectCluster::class.java.name) + const val CLUSTER_ID: UInt = 80u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt new file mode 100644 index 00000000000000..be084ccb9ff782 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt @@ -0,0 +1,1576 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class NetworkCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ScanNetworksResponse( + val networkingStatus: UByte, + val debugText: String?, + val wiFiScanResults: List?, + val threadScanResults: List? + ) + + class NetworkConfigResponse( + val networkingStatus: UByte, + val debugText: String?, + val networkIndex: UByte?, + val clientIdentity: ByteArray?, + val possessionSignature: ByteArray? + ) + + class ConnectNetworkResponse( + val networkingStatus: UByte, + val debugText: String?, + val errorValue: Int? + ) + + class QueryIdentityResponse(val identity: ByteArray, val possessionSignature: ByteArray?) + + class NetworksAttribute(val value: List) + + class LastNetworkingStatusAttribute(val value: UByte?) + + class LastNetworkIDAttribute(val value: ByteArray?) + + class LastConnectErrorValueAttribute(val value: Int?) + + class SupportedWiFiBandsAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun scanNetworks( + ssid: ByteArray?, + breadcrumb: ULong?, + timedInvokeTimeoutMs: Int? = null + ): ScanNetworksResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SSID_REQ: Int = 0 + ssid?.let { tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) } + + val TAG_BREADCRUMB_REQ: Int = 1 + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NETWORKING_STATUS: Int = 0 + var networkingStatus_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + val TAG_WI_FI_SCAN_RESULTS: Int = 2 + var wiFiScanResults_decoded: List? = + null + + val TAG_THREAD_SCAN_RESULTS: Int = 3 + var threadScanResults_decoded: + List? = + null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) { + wiFiScanResults_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add( + NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) { + threadScanResults_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add( + NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (networkingStatus_decoded == null) { + throw IllegalStateException("networkingStatus not found in TLV") + } + + tlvReader.exitContainer() + + return ScanNetworksResponse( + networkingStatus_decoded, + debugText_decoded, + wiFiScanResults_decoded, + threadScanResults_decoded + ) + } + + suspend fun addOrUpdateWiFiNetwork( + ssid: ByteArray, + credentials: ByteArray, + breadcrumb: ULong?, + networkIdentity: ByteArray?, + clientIdentifier: ByteArray?, + possessionNonce: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): NetworkConfigResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SSID_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) + + val TAG_CREDENTIALS_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_CREDENTIALS_REQ), credentials) + + val TAG_BREADCRUMB_REQ: Int = 2 + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + + val TAG_NETWORK_IDENTITY_REQ: Int = 3 + networkIdentity?.let { + tlvWriter.put(ContextSpecificTag(TAG_NETWORK_IDENTITY_REQ), networkIdentity) + } + + val TAG_CLIENT_IDENTIFIER_REQ: Int = 4 + clientIdentifier?.let { + tlvWriter.put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER_REQ), clientIdentifier) + } + + val TAG_POSSESSION_NONCE_REQ: Int = 5 + possessionNonce?.let { + tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NETWORKING_STATUS: Int = 0 + var networkingStatus_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + val TAG_NETWORK_INDEX: Int = 2 + var networkIndex_decoded: UByte? = null + + val TAG_CLIENT_IDENTITY: Int = 3 + var clientIdentity_decoded: ByteArray? = null + + val TAG_POSSESSION_SIGNATURE: Int = 4 + var possessionSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (networkingStatus_decoded == null) { + throw IllegalStateException("networkingStatus not found in TLV") + } + + tlvReader.exitContainer() + + return NetworkConfigResponse( + networkingStatus_decoded, + debugText_decoded, + networkIndex_decoded, + clientIdentity_decoded, + possessionSignature_decoded + ) + } + + suspend fun addOrUpdateThreadNetwork( + operationalDataset: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeoutMs: Int? = null + ): NetworkConfigResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPERATIONAL_DATASET_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_OPERATIONAL_DATASET_REQ), operationalDataset) + + val TAG_BREADCRUMB_REQ: Int = 1 + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NETWORKING_STATUS: Int = 0 + var networkingStatus_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + val TAG_NETWORK_INDEX: Int = 2 + var networkIndex_decoded: UByte? = null + + val TAG_CLIENT_IDENTITY: Int = 3 + var clientIdentity_decoded: ByteArray? = null + + val TAG_POSSESSION_SIGNATURE: Int = 4 + var possessionSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (networkingStatus_decoded == null) { + throw IllegalStateException("networkingStatus not found in TLV") + } + + tlvReader.exitContainer() + + return NetworkConfigResponse( + networkingStatus_decoded, + debugText_decoded, + networkIndex_decoded, + clientIdentity_decoded, + possessionSignature_decoded + ) + } + + suspend fun removeNetwork( + networkID: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeoutMs: Int? = null + ): NetworkConfigResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NETWORK_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) + + val TAG_BREADCRUMB_REQ: Int = 1 + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NETWORKING_STATUS: Int = 0 + var networkingStatus_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + val TAG_NETWORK_INDEX: Int = 2 + var networkIndex_decoded: UByte? = null + + val TAG_CLIENT_IDENTITY: Int = 3 + var clientIdentity_decoded: ByteArray? = null + + val TAG_POSSESSION_SIGNATURE: Int = 4 + var possessionSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (networkingStatus_decoded == null) { + throw IllegalStateException("networkingStatus not found in TLV") + } + + tlvReader.exitContainer() + + return NetworkConfigResponse( + networkingStatus_decoded, + debugText_decoded, + networkIndex_decoded, + clientIdentity_decoded, + possessionSignature_decoded + ) + } + + suspend fun connectNetwork( + networkID: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeoutMs: Int? = null + ): ConnectNetworkResponse { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NETWORK_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) + + val TAG_BREADCRUMB_REQ: Int = 1 + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NETWORKING_STATUS: Int = 0 + var networkingStatus_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + val TAG_ERROR_VALUE: Int = 2 + var errorValue_decoded: Int? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) { + errorValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getInt(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (networkingStatus_decoded == null) { + throw IllegalStateException("networkingStatus not found in TLV") + } + + tlvReader.exitContainer() + + return ConnectNetworkResponse(networkingStatus_decoded, debugText_decoded, errorValue_decoded) + } + + suspend fun reorderNetwork( + networkID: ByteArray, + networkIndex: UByte, + breadcrumb: ULong?, + timedInvokeTimeoutMs: Int? = null + ): NetworkConfigResponse { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NETWORK_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) + + val TAG_NETWORK_INDEX_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_NETWORK_INDEX_REQ), networkIndex) + + val TAG_BREADCRUMB_REQ: Int = 2 + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NETWORKING_STATUS: Int = 0 + var networkingStatus_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 1 + var debugText_decoded: String? = null + + val TAG_NETWORK_INDEX: Int = 2 + var networkIndex_decoded: UByte? = null + + val TAG_CLIENT_IDENTITY: Int = 3 + var clientIdentity_decoded: ByteArray? = null + + val TAG_POSSESSION_SIGNATURE: Int = 4 + var possessionSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (networkingStatus_decoded == null) { + throw IllegalStateException("networkingStatus not found in TLV") + } + + tlvReader.exitContainer() + + return NetworkConfigResponse( + networkingStatus_decoded, + debugText_decoded, + networkIndex_decoded, + clientIdentity_decoded, + possessionSignature_decoded + ) + } + + suspend fun queryIdentity( + keyIdentifier: ByteArray, + possessionNonce: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): QueryIdentityResponse { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_KEY_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_KEY_IDENTIFIER_REQ), keyIdentifier) + + val TAG_POSSESSION_NONCE_REQ: Int = 1 + possessionNonce?.let { + tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_IDENTITY: Int = 0 + var identity_decoded: ByteArray? = null + + val TAG_POSSESSION_SIGNATURE: Int = 1 + var possessionSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_IDENTITY)) { + identity_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (identity_decoded == null) { + throw IllegalStateException("identity not found in TLV") + } + + tlvReader.exitContainer() + + return QueryIdentityResponse(identity_decoded, possessionSignature_decoded) + } + + suspend fun readMaxNetworksAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxnetworks attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readNetworksAttribute(): NetworksAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Networks attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return NetworksAttribute(decodedValue) + } + + suspend fun readScanMaxTimeSecondsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scanmaxtimeseconds attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readConnectMaxTimeSecondsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Connectmaxtimeseconds attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInterfaceEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Interfaceenabled attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeInterfaceEnabledAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lastnetworkingstatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LastNetworkingStatusAttribute(decodedValue) + } + + suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lastnetworkid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LastNetworkIDAttribute(decodedValue) + } + + suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lastconnecterrorvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LastConnectErrorValueAttribute(decodedValue) + } + + suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedwifibands attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return SupportedWiFiBandsAttribute(decodedValue) + } + + suspend fun readSupportedThreadFeaturesAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedthreadfeatures attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readThreadVersionAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Threadversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(NetworkCommissioningCluster::class.java.name) + const val CLUSTER_ID: UInt = 49u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..715be5197a8d6f --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt @@ -0,0 +1,692 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class NitrogenDioxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1043u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt new file mode 100644 index 00000000000000..8696b431542018 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt @@ -0,0 +1,1101 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OccupancySensingCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readOccupancyAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupancy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOccupancySensorTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupancysensortype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOccupancySensorTypeBitmapAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupancysensortypebitmap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Piroccupiedtounoccupieddelay attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writePIROccupiedToUnoccupiedDelayAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Pirunoccupiedtooccupieddelay attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writePIRUnoccupiedToOccupiedDelayAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 17u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writePIRUnoccupiedToOccupiedThresholdAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 18u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUltrasonicOccupiedToUnoccupiedDelayAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 32u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUltrasonicUnoccupiedToOccupiedDelayAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 33u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUltrasonicUnoccupiedToOccupiedThresholdAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 34u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writePhysicalContactOccupiedToUnoccupiedDelayAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 48u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writePhysicalContactUnoccupiedToOccupiedDelayAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 49u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writePhysicalContactUnoccupiedToOccupiedThresholdAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 50u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OccupancySensingCluster::class.java.name) + const val CLUSTER_ID: UInt = 1030u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt new file mode 100644 index 00000000000000..ff372b51cd8df1 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt @@ -0,0 +1,718 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) { + class StartUpOnOffAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun off(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun on(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun toggle(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun offWithEffect( + effectIdentifier: UByte, + effectVariant: UByte, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 64u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_EFFECT_IDENTIFIER_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) + + val TAG_EFFECT_VARIANT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun onWithRecallGlobalScene(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 65u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun onWithTimedOff( + onOffControl: UByte, + onTime: UShort, + offWaitTime: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 66u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ON_OFF_CONTROL_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ON_OFF_CONTROL_REQ), onOffControl) + + val TAG_ON_TIME_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ON_TIME_REQ), onTime) + + val TAG_OFF_WAIT_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readOnOffAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onoff attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readGlobalSceneControlAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Globalscenecontrol attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readOnTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ontime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOnTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16385u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOffWaitTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Offwaittime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOffWaitTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16386u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startuponoff attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpOnOffAttribute(decodedValue) + } + + suspend fun writeStartUpOnOffAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16387u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OnOffCluster::class.java.name) + const val CLUSTER_ID: UInt = 6u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt new file mode 100644 index 00000000000000..ce7a5fcee8adb2 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt @@ -0,0 +1,369 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OnOffSwitchConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readSwitchTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Switchtype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readSwitchActionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Switchactions attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeSwitchActionsAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OnOffSwitchConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 7u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt new file mode 100644 index 00000000000000..9cf448add35ed1 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt @@ -0,0 +1,1044 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OperationalCredentialsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AttestationResponse( + val attestationElements: ByteArray, + val attestationSignature: ByteArray + ) + + class CertificateChainResponse(val certificate: ByteArray) + + class CSRResponse(val NOCSRElements: ByteArray, val attestationSignature: ByteArray) + + class NOCResponse(val statusCode: UByte, val fabricIndex: UByte?, val debugText: String?) + + class NOCsAttribute(val value: List) + + class FabricsAttribute(val value: List) + + class TrustedRootCertificatesAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun attestationRequest( + attestationNonce: ByteArray, + timedInvokeTimeoutMs: Int? = null + ): AttestationResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ATTESTATION_NONCE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ATTESTATION_ELEMENTS: Int = 0 + var attestationElements_decoded: ByteArray? = null + + val TAG_ATTESTATION_SIGNATURE: Int = 1 + var attestationSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) { + attestationElements_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { + attestationSignature_decoded = tlvReader.getByteArray(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (attestationElements_decoded == null) { + throw IllegalStateException("attestationElements not found in TLV") + } + + if (attestationSignature_decoded == null) { + throw IllegalStateException("attestationSignature not found in TLV") + } + + tlvReader.exitContainer() + + return AttestationResponse(attestationElements_decoded, attestationSignature_decoded) + } + + suspend fun certificateChainRequest( + certificateType: UByte, + timedInvokeTimeoutMs: Int? = null + ): CertificateChainResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_CERTIFICATE_TYPE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_CERTIFICATE: Int = 0 + var certificate_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_CERTIFICATE)) { + certificate_decoded = tlvReader.getByteArray(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (certificate_decoded == null) { + throw IllegalStateException("certificate not found in TLV") + } + + tlvReader.exitContainer() + + return CertificateChainResponse(certificate_decoded) + } + + suspend fun CSRRequest( + CSRNonce: ByteArray, + isForUpdateNOC: Boolean?, + timedInvokeTimeoutMs: Int? = null + ): CSRResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_C_S_R_NONCE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_C_S_R_NONCE_REQ), CSRNonce) + + val TAG_IS_FOR_UPDATE_N_O_C_REQ: Int = 1 + isForUpdateNOC?.let { + tlvWriter.put(ContextSpecificTag(TAG_IS_FOR_UPDATE_N_O_C_REQ), isForUpdateNOC) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_N_O_C_S_R_ELEMENTS: Int = 0 + var NOCSRElements_decoded: ByteArray? = null + + val TAG_ATTESTATION_SIGNATURE: Int = 1 + var attestationSignature_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) { + NOCSRElements_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { + attestationSignature_decoded = tlvReader.getByteArray(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (NOCSRElements_decoded == null) { + throw IllegalStateException("NOCSRElements not found in TLV") + } + + if (attestationSignature_decoded == null) { + throw IllegalStateException("attestationSignature not found in TLV") + } + + tlvReader.exitContainer() + + return CSRResponse(NOCSRElements_decoded, attestationSignature_decoded) + } + + suspend fun addNOC( + NOCValue: ByteArray, + ICACValue: ByteArray?, + IPKValue: ByteArray, + caseAdminSubject: ULong, + adminVendorId: UShort, + timedInvokeTimeoutMs: Int? = null + ): NOCResponse { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_N_O_C_VALUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) + + val TAG_I_C_A_C_VALUE_REQ: Int = 1 + ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } + + val TAG_I_P_K_VALUE_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_I_P_K_VALUE_REQ), IPKValue) + + val TAG_CASE_ADMIN_SUBJECT_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_CASE_ADMIN_SUBJECT_REQ), caseAdminSubject) + + val TAG_ADMIN_VENDOR_ID_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS_CODE: Int = 0 + var statusCode_decoded: UByte? = null + + val TAG_FABRIC_INDEX: Int = 1 + var fabricIndex_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 2 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (statusCode_decoded == null) { + throw IllegalStateException("statusCode not found in TLV") + } + + tlvReader.exitContainer() + + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + } + + suspend fun updateNOC( + NOCValue: ByteArray, + ICACValue: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): NOCResponse { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_N_O_C_VALUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) + + val TAG_I_C_A_C_VALUE_REQ: Int = 1 + ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS_CODE: Int = 0 + var statusCode_decoded: UByte? = null + + val TAG_FABRIC_INDEX: Int = 1 + var fabricIndex_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 2 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (statusCode_decoded == null) { + throw IllegalStateException("statusCode not found in TLV") + } + + tlvReader.exitContainer() + + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + } + + suspend fun updateFabricLabel(label: String, timedInvokeTimeoutMs: Int? = null): NOCResponse { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LABEL_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS_CODE: Int = 0 + var statusCode_decoded: UByte? = null + + val TAG_FABRIC_INDEX: Int = 1 + var fabricIndex_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 2 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (statusCode_decoded == null) { + throw IllegalStateException("statusCode not found in TLV") + } + + tlvReader.exitContainer() + + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + } + + suspend fun removeFabric(fabricIndex: UByte, timedInvokeTimeoutMs: Int? = null): NOCResponse { + val commandId: UInt = 10u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_FABRIC_INDEX_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS_CODE: Int = 0 + var statusCode_decoded: UByte? = null + + val TAG_FABRIC_INDEX: Int = 1 + var fabricIndex_decoded: UByte? = null + + val TAG_DEBUG_TEXT: Int = 2 + var debugText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (statusCode_decoded == null) { + throw IllegalStateException("statusCode not found in TLV") + } + + tlvReader.exitContainer() + + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + } + + suspend fun addTrustedRootCertificate( + rootCACertificate: ByteArray, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 11u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ROOT_C_A_CERTIFICATE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readNOCsAttribute(): NOCsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nocs attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return NOCsAttribute(decodedValue) + } + + suspend fun readFabricsAttribute(): FabricsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Fabrics attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return FabricsAttribute(decodedValue) + } + + suspend fun readSupportedFabricsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedfabrics attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readCommissionedFabricsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Commissionedfabrics attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Trustedrootcertificates attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return TrustedRootCertificatesAttribute(decodedValue) + } + + suspend fun readCurrentFabricIndexAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentfabricindex attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OperationalCredentialsCluster::class.java.name) + const val CLUSTER_ID: UInt = 62u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt new file mode 100644 index 00000000000000..1fa39c3ce846ee --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt @@ -0,0 +1,684 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OperationalCommandResponse( + val commandResponseState: OperationalStateClusterErrorStateStruct + ) + + class PhaseListAttribute(val value: List?) + + class CurrentPhaseAttribute(val value: UByte?) + + class CountdownTimeAttribute(val value: UInt?) + + class OperationalStateListAttribute( + val value: List + ) + + class OperationalErrorAttribute(val value: OperationalStateClusterErrorStateStruct) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun pause(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun stop(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun start(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun resume(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PhaseListAttribute(decodedValue) + } + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPhaseAttribute(decodedValue) + } + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CountdownTimeAttribute(decodedValue) + } + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return OperationalStateListAttribute(decodedValue) + } + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: OperationalStateClusterErrorStateStruct = + OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + + return OperationalErrorAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OperationalStateCluster::class.java.name) + const val CLUSTER_ID: UInt = 96u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt new file mode 100644 index 00000000000000..42062ad4b77498 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt @@ -0,0 +1,590 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OtaSoftwareUpdateProviderCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class QueryImageResponse( + val status: UByte, + val delayedActionTime: UInt?, + val imageURI: String?, + val softwareVersion: UInt?, + val softwareVersionString: String?, + val updateToken: ByteArray?, + val userConsentNeeded: Boolean?, + val metadataForRequestor: ByteArray? + ) + + class ApplyUpdateResponse(val action: UByte, val delayedActionTime: UInt) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun queryImage( + vendorID: UShort, + productID: UShort, + softwareVersion: UInt, + protocolsSupported: List, + hardwareVersion: UShort?, + location: String?, + requestorCanConsent: Boolean?, + metadataForProvider: ByteArray?, + timedInvokeTimeoutMs: Int? = null + ): QueryImageResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_VENDOR_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_VENDOR_I_D_REQ), vendorID) + + val TAG_PRODUCT_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_PRODUCT_I_D_REQ), productID) + + val TAG_SOFTWARE_VERSION_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) + + val TAG_PROTOCOLS_SUPPORTED_REQ: Int = 3 + tlvWriter.startArray(ContextSpecificTag(TAG_PROTOCOLS_SUPPORTED_REQ)) + for (item in protocolsSupported.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + + val TAG_HARDWARE_VERSION_REQ: Int = 4 + hardwareVersion?.let { + tlvWriter.put(ContextSpecificTag(TAG_HARDWARE_VERSION_REQ), hardwareVersion) + } + + val TAG_LOCATION_REQ: Int = 5 + location?.let { tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) } + + val TAG_REQUESTOR_CAN_CONSENT_REQ: Int = 6 + requestorCanConsent?.let { + tlvWriter.put(ContextSpecificTag(TAG_REQUESTOR_CAN_CONSENT_REQ), requestorCanConsent) + } + + val TAG_METADATA_FOR_PROVIDER_REQ: Int = 7 + metadataForProvider?.let { + tlvWriter.put(ContextSpecificTag(TAG_METADATA_FOR_PROVIDER_REQ), metadataForProvider) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DELAYED_ACTION_TIME: Int = 1 + var delayedActionTime_decoded: UInt? = null + + val TAG_IMAGE_U_R_I: Int = 2 + var imageURI_decoded: String? = null + + val TAG_SOFTWARE_VERSION: Int = 3 + var softwareVersion_decoded: UInt? = null + + val TAG_SOFTWARE_VERSION_STRING: Int = 4 + var softwareVersionString_decoded: String? = null + + val TAG_UPDATE_TOKEN: Int = 5 + var updateToken_decoded: ByteArray? = null + + val TAG_USER_CONSENT_NEEDED: Int = 6 + var userConsentNeeded_decoded: Boolean? = null + + val TAG_METADATA_FOR_REQUESTOR: Int = 7 + var metadataForRequestor_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { + delayedActionTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) { + imageURI_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) { + softwareVersion_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) { + softwareVersionString_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) { + updateToken_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) { + userConsentNeeded_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) { + metadataForRequestor_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return QueryImageResponse( + status_decoded, + delayedActionTime_decoded, + imageURI_decoded, + softwareVersion_decoded, + softwareVersionString_decoded, + updateToken_decoded, + userConsentNeeded_decoded, + metadataForRequestor_decoded + ) + } + + suspend fun applyUpdateRequest( + updateToken: ByteArray, + newVersion: UInt, + timedInvokeTimeoutMs: Int? = null + ): ApplyUpdateResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_UPDATE_TOKEN_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) + + val TAG_NEW_VERSION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ACTION: Int = 0 + var action_decoded: UByte? = null + + val TAG_DELAYED_ACTION_TIME: Int = 1 + var delayedActionTime_decoded: UInt? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ACTION)) { + action_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { + delayedActionTime_decoded = tlvReader.getUInt(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (action_decoded == null) { + throw IllegalStateException("action not found in TLV") + } + + if (delayedActionTime_decoded == null) { + throw IllegalStateException("delayedActionTime not found in TLV") + } + + tlvReader.exitContainer() + + return ApplyUpdateResponse(action_decoded, delayedActionTime_decoded) + } + + suspend fun notifyUpdateApplied( + updateToken: ByteArray, + softwareVersion: UInt, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_UPDATE_TOKEN_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) + + val TAG_SOFTWARE_VERSION_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OtaSoftwareUpdateProviderCluster::class.java.name) + const val CLUSTER_ID: UInt = 41u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt new file mode 100644 index 00000000000000..66000d0ce29082 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt @@ -0,0 +1,505 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OtaSoftwareUpdateRequestorCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class DefaultOTAProvidersAttribute( + val value: List + ) + + class UpdateStateProgressAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun announceOTAProvider( + providerNodeID: ULong, + vendorID: UShort, + announcementReason: UByte, + metadataForNode: ByteArray?, + endpoint: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_PROVIDER_NODE_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_PROVIDER_NODE_I_D_REQ), providerNodeID) + + val TAG_VENDOR_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_VENDOR_I_D_REQ), vendorID) + + val TAG_ANNOUNCEMENT_REASON_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_ANNOUNCEMENT_REASON_REQ), announcementReason) + + val TAG_METADATA_FOR_NODE_REQ: Int = 3 + metadataForNode?.let { + tlvWriter.put(ContextSpecificTag(TAG_METADATA_FOR_NODE_REQ), metadataForNode) + } + + val TAG_ENDPOINT_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Defaultotaproviders attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return DefaultOTAProvidersAttribute(decodedValue) + } + + suspend fun writeDefaultOTAProvidersAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUpdatePossibleAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Updatepossible attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readUpdateStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Updatestate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Updatestateprogress attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return UpdateStateProgressAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OtaSoftwareUpdateRequestorCluster::class.java.name) + const val CLUSTER_ID: UInt = 42u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt new file mode 100644 index 00000000000000..5860562564f696 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt @@ -0,0 +1,686 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OvenCavityOperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OperationalCommandResponse( + val commandResponseState: OvenCavityOperationalStateClusterErrorStateStruct + ) + + class PhaseListAttribute(val value: List?) + + class CurrentPhaseAttribute(val value: UByte?) + + class CountdownTimeAttribute(val value: UInt?) + + class OperationalStateListAttribute( + val value: List + ) + + class OperationalErrorAttribute(val value: OvenCavityOperationalStateClusterErrorStateStruct) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun pause(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun stop(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun start(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun resume(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PhaseListAttribute(decodedValue) + } + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPhaseAttribute(decodedValue) + } + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CountdownTimeAttribute(decodedValue) + } + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + + return OperationalStateListAttribute(decodedValue) + } + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + + return OperationalErrorAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OvenCavityOperationalStateCluster::class.java.name) + const val CLUSTER_ID: UInt = 72u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt new file mode 100644 index 00000000000000..d9984fef2ed1ef --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt @@ -0,0 +1,576 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class OvenModeCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) + + class StartUpModeAttribute(val value: UByte?) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeoutMs: Int? = null + ): ChangeToModeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_STATUS_TEXT: Int = 1 + var statusText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeToModeResponse(status_decoded, statusText_decoded) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpModeAttribute(decodedValue) + } + + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OvenModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 73u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..2cc23fa5ba0257 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt @@ -0,0 +1,691 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class OzoneConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(OzoneConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1045u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..a0fb883cb6f6a7 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt @@ -0,0 +1,691 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class Pm10ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(Pm10ConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1069u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..6ce088f31b6816 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt @@ -0,0 +1,691 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class Pm1ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(Pm1ConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1068u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..a09517acf21508 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt @@ -0,0 +1,691 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class Pm25ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(Pm25ConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1066u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt new file mode 100644 index 00000000000000..f701ae91a1a006 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt @@ -0,0 +1,1478 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) { + class WiredAssessedInputVoltageAttribute(val value: UInt?) + + class WiredAssessedInputFrequencyAttribute(val value: UShort?) + + class WiredAssessedCurrentAttribute(val value: UInt?) + + class ActiveWiredFaultsAttribute(val value: List?) + + class BatVoltageAttribute(val value: UInt?) + + class BatPercentRemainingAttribute(val value: UByte?) + + class BatTimeRemainingAttribute(val value: UInt?) + + class ActiveBatFaultsAttribute(val value: List?) + + class BatTimeToFullChargeAttribute(val value: UInt?) + + class BatChargingCurrentAttribute(val value: UInt?) + + class ActiveBatChargeFaultsAttribute(val value: List?) + + class EndpointListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Status attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOrderAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Order attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readDescriptionAttribute(): String { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Description attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wiredassessedinputvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return WiredAssessedInputVoltageAttribute(decodedValue) + } + + suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wiredassessedinputfrequency attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return WiredAssessedInputFrequencyAttribute(decodedValue) + } + + suspend fun readWiredCurrentTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wiredcurrenttype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wiredassessedcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return WiredAssessedCurrentAttribute(decodedValue) + } + + suspend fun readWiredNominalVoltageAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wirednominalvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readWiredMaximumCurrentAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wiredmaximumcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readWiredPresentAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wiredpresent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activewiredfaults attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveWiredFaultsAttribute(decodedValue) + } + + suspend fun readBatVoltageAttribute(): BatVoltageAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batvoltage attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BatVoltageAttribute(decodedValue) + } + + suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batpercentremaining attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BatPercentRemainingAttribute(decodedValue) + } + + suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Battimeremaining attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BatTimeRemainingAttribute(decodedValue) + } + + suspend fun readBatChargeLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batchargelevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatReplacementNeededAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batreplacementneeded attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatReplaceabilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batreplaceability attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatPresentAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batpresent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activebatfaults attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveBatFaultsAttribute(decodedValue) + } + + suspend fun readBatReplacementDescriptionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batreplacementdescription attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatCommonDesignationAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batcommondesignation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatANSIDesignationAttribute(): String? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batansidesignation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatIECDesignationAttribute(): String? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batiecdesignation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatApprovedChemistryAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batapprovedchemistry attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatCapacityAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batcapacity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatQuantityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batquantity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatChargeStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batchargestate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Battimetofullcharge attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BatTimeToFullChargeAttribute(decodedValue) + } + + suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batfunctionalwhilecharging attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batchargingcurrent attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BatChargingCurrentAttribute(decodedValue) + } + + suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activebatchargefaults attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ActiveBatChargeFaultsAttribute(decodedValue) + } + + suspend fun readEndpointListAttribute(): EndpointListAttribute { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Endpointlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EndpointListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(PowerSourceCluster::class.java.name) + const val CLUSTER_ID: UInt = 47u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt new file mode 100644 index 00000000000000..efd82e8a519fc7 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt @@ -0,0 +1,300 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class PowerSourceConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SourcesAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readSourcesAttribute(): SourcesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Sources attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return SourcesAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(PowerSourceConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 46u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt new file mode 100644 index 00000000000000..4d4ec17577fc6d --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt @@ -0,0 +1,614 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class PressureMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Short?) + + class MinMeasuredValueAttribute(val value: Short?) + + class MaxMeasuredValueAttribute(val value: Short?) + + class ScaledValueAttribute(val value: Short?) + + class MinScaledValueAttribute(val value: Short?) + + class MaxScaledValueAttribute(val value: Short?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readScaledValueAttribute(): ScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scaledvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ScaledValueAttribute(decodedValue) + } + + suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minscaledvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinScaledValueAttribute(decodedValue) + } + + suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxscaledvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxScaledValueAttribute(decodedValue) + } + + suspend fun readScaledToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scaledtolerance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readScaleAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scale attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(PressureMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1027u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt new file mode 100644 index 00000000000000..fbabea98973688 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt @@ -0,0 +1,260 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class ProxyConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ProxyConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 66u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt new file mode 100644 index 00000000000000..e5f72cc56f44e6 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt @@ -0,0 +1,260 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class ProxyDiscoveryCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ProxyDiscoveryCluster::class.java.name) + const val CLUSTER_ID: UInt = 67u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt new file mode 100644 index 00000000000000..26764e35031074 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt @@ -0,0 +1,257 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ProxyValidCluster::class.java.name) + const val CLUSTER_ID: UInt = 68u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt new file mode 100644 index 00000000000000..822765f8c4f85a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt @@ -0,0 +1,260 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class PulseWidthModulationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(PulseWidthModulationCluster::class.java.name) + const val CLUSTER_ID: UInt = 28u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt new file mode 100644 index 00000000000000..7d6d62984c3579 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt @@ -0,0 +1,1356 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class PumpConfigurationAndControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MaxPressureAttribute(val value: Short?) + + class MaxSpeedAttribute(val value: UShort?) + + class MaxFlowAttribute(val value: UShort?) + + class MinConstPressureAttribute(val value: Short?) + + class MaxConstPressureAttribute(val value: Short?) + + class MinCompPressureAttribute(val value: Short?) + + class MaxCompPressureAttribute(val value: Short?) + + class MinConstSpeedAttribute(val value: UShort?) + + class MaxConstSpeedAttribute(val value: UShort?) + + class MinConstFlowAttribute(val value: UShort?) + + class MaxConstFlowAttribute(val value: UShort?) + + class MinConstTempAttribute(val value: Short?) + + class MaxConstTempAttribute(val value: Short?) + + class CapacityAttribute(val value: Short?) + + class SpeedAttribute(val value: UShort?) + + class LifetimeRunningHoursAttribute(val value: UInt?) + + class PowerAttribute(val value: UInt?) + + class LifetimeEnergyConsumedAttribute(val value: UInt?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMaxPressureAttribute(): MaxPressureAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxpressure attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxPressureAttribute(decodedValue) + } + + suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxspeed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxSpeedAttribute(decodedValue) + } + + suspend fun readMaxFlowAttribute(): MaxFlowAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxflow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxFlowAttribute(decodedValue) + } + + suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minconstpressure attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinConstPressureAttribute(decodedValue) + } + + suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxconstpressure attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxConstPressureAttribute(decodedValue) + } + + suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Mincomppressure attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinCompPressureAttribute(decodedValue) + } + + suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxcomppressure attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxCompPressureAttribute(decodedValue) + } + + suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minconstspeed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinConstSpeedAttribute(decodedValue) + } + + suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxconstspeed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxConstSpeedAttribute(decodedValue) + } + + suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minconstflow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinConstFlowAttribute(decodedValue) + } + + suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxconstflow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxConstFlowAttribute(decodedValue) + } + + suspend fun readMinConstTempAttribute(): MinConstTempAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minconsttemp attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinConstTempAttribute(decodedValue) + } + + suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxconsttemp attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxConstTempAttribute(decodedValue) + } + + suspend fun readPumpStatusAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Pumpstatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readEffectiveOperationModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Effectiveoperationmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readEffectiveControlModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Effectivecontrolmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readCapacityAttribute(): CapacityAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Capacity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CapacityAttribute(decodedValue) + } + + suspend fun readSpeedAttribute(): SpeedAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Speed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SpeedAttribute(decodedValue) + } + + suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lifetimerunninghours attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LifetimeRunningHoursAttribute(decodedValue) + } + + suspend fun writeLifetimeRunningHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 21u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readPowerAttribute(): PowerAttribute { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Power attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PowerAttribute(decodedValue) + } + + suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lifetimeenergyconsumed attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LifetimeEnergyConsumedAttribute(decodedValue) + } + + suspend fun writeLifetimeEnergyConsumedAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 23u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOperationModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeOperationModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 32u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readControlModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Controlmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeControlModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 33u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(PumpConfigurationAndControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 512u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..adbb2c5b1bd3c5 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt @@ -0,0 +1,691 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class RadonConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(RadonConcentrationMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1071u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt new file mode 100644 index 00000000000000..5a524b7b1de9bb --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt @@ -0,0 +1,353 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class RefrigeratorAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMaskAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Mask attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readStateAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "State attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readSupportedAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(RefrigeratorAlarmCluster::class.java.name) + const val CLUSTER_ID: UInt = 87u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt new file mode 100644 index 00000000000000..ae1b353d135399 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt @@ -0,0 +1,587 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class RefrigeratorAndTemperatureControlledCabinetModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute( + val value: List + ) + + class StartUpModeAttribute(val value: UByte?) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeoutMs: Int? = null + ): ChangeToModeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_STATUS_TEXT: Int = 1 + var statusText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeToModeResponse(status_decoded, statusText_decoded) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StartUpModeAttribute(decodedValue) + } + + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 82u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt new file mode 100644 index 00000000000000..ac269f3eb80ce2 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt @@ -0,0 +1,413 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class RelativeHumidityMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) + + class MinMeasuredValueAttribute(val value: UShort?) + + class MaxMeasuredValueAttribute(val value: UShort?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(RelativeHumidityMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1029u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt new file mode 100644 index 00000000000000..e0aec7f0b69d1b --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt @@ -0,0 +1,494 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class RvcCleanModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeoutMs: Int? = null + ): ChangeToModeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_STATUS_TEXT: Int = 1 + var statusText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeToModeResponse(status_decoded, statusText_decoded) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(RvcCleanModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 85u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt new file mode 100644 index 00000000000000..fd6bdf869add7d --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt @@ -0,0 +1,684 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class RvcOperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OperationalCommandResponse( + val commandResponseState: RvcOperationalStateClusterErrorStateStruct + ) + + class PhaseListAttribute(val value: List?) + + class CurrentPhaseAttribute(val value: UByte?) + + class CountdownTimeAttribute(val value: UInt?) + + class OperationalStateListAttribute( + val value: List + ) + + class OperationalErrorAttribute(val value: RvcOperationalStateClusterErrorStateStruct) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun pause(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun stop(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun start(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun resume(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_COMMAND_RESPONSE_STATE: Int = 0 + var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (commandResponseState_decoded == null) { + throw IllegalStateException("commandResponseState not found in TLV") + } + + tlvReader.exitContainer() + + return OperationalCommandResponse(commandResponseState_decoded) + } + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PhaseListAttribute(decodedValue) + } + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPhaseAttribute(decodedValue) + } + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CountdownTimeAttribute(decodedValue) + } + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return OperationalStateListAttribute(decodedValue) + } + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: RvcOperationalStateClusterErrorStateStruct = + RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + + return OperationalErrorAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(RvcOperationalStateCluster::class.java.name) + const val CLUSTER_ID: UInt = 97u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt new file mode 100644 index 00000000000000..a8007f66cec08c --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt @@ -0,0 +1,491 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class RvcRunModeCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) + + class OnModeAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeoutMs: Int? = null + ): ChangeToModeResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_STATUS_TEXT: Int = 1 + var statusText_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return ChangeToModeResponse(status_decoded, statusText_decoded) + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return SupportedModesAttribute(decodedValue) + } + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OnModeAttribute(decodedValue) + } + + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(RvcRunModeCluster::class.java.name) + const val CLUSTER_ID: UInt = 84u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt new file mode 100644 index 00000000000000..3b8c7290bdf743 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt @@ -0,0 +1,415 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SampleMeiCluster(private val controller: MatterController, private val endpointId: UShort) { + class AddArgumentsResponse(val returnValue: UByte) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun ping(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun addArguments( + arg1: UByte, + arg2: UByte, + timedInvokeTimeoutMs: Int? = null + ): AddArgumentsResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + + val TAG_ARG2_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_RETURN_VALUE: Int = 0 + var returnValue_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (returnValue_decoded == null) { + throw IllegalStateException("returnValue not found in TLV") + } + + tlvReader.exitContainer() + + return AddArgumentsResponse(returnValue_decoded) + } + + suspend fun readFlipFlopAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Flipflop attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeFlipFlopAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(SampleMeiCluster::class.java.name) + const val CLUSTER_ID: UInt = 4294048800u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesCluster.kt new file mode 100644 index 00000000000000..e5c8a3894ea1d8 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesCluster.kt @@ -0,0 +1,1505 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ScenesCluster(private val controller: MatterController, private val endpointId: UShort) { + class AddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + + class ViewSceneResponse( + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UShort?, + val sceneName: String?, + val extensionFieldSets: List? + ) + + class RemoveSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + + class RemoveAllScenesResponse(val status: UByte, val groupID: UShort) + + class StoreSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + + class GetSceneMembershipResponse( + val status: UByte, + val capacity: UByte?, + val groupID: UShort, + val sceneList: List? + ) + + class EnhancedAddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + + class EnhancedViewSceneResponse( + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UShort?, + val sceneName: String?, + val extensionFieldSets: List? + ) + + class CopySceneResponse( + val status: UByte, + val groupIdentifierFrom: UShort, + val sceneIdentifierFrom: UByte + ) + + class LastConfiguredByAttribute(val value: ULong?) + + class FabricSceneInfoAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun addScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UShort, + sceneName: String, + extensionFieldSets: List, + timedInvokeTimeoutMs: Int? = null + ): AddSceneResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_SCENE_NAME_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_NAME_REQ), sceneName) + + val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 + tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_SCENE_I_D: Int = 2 + var sceneID_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (sceneID_decoded == null) { + throw IllegalStateException("sceneID not found in TLV") + } + + tlvReader.exitContainer() + + return AddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + } + + suspend fun viewScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeoutMs: Int? = null + ): ViewSceneResponse { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_SCENE_I_D: Int = 2 + var sceneID_decoded: UByte? = null + + val TAG_TRANSITION_TIME: Int = 3 + var transitionTime_decoded: UShort? = null + + val TAG_SCENE_NAME: Int = 4 + var sceneName_decoded: String? = null + + val TAG_EXTENSION_FIELD_SETS: Int = 5 + var extensionFieldSets_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { + transitionTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { + sceneName_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { + extensionFieldSets_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (sceneID_decoded == null) { + throw IllegalStateException("sceneID not found in TLV") + } + + tlvReader.exitContainer() + + return ViewSceneResponse( + status_decoded, + groupID_decoded, + sceneID_decoded, + transitionTime_decoded, + sceneName_decoded, + extensionFieldSets_decoded + ) + } + + suspend fun removeScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeoutMs: Int? = null + ): RemoveSceneResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_SCENE_I_D: Int = 2 + var sceneID_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (sceneID_decoded == null) { + throw IllegalStateException("sceneID not found in TLV") + } + + tlvReader.exitContainer() + + return RemoveSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + } + + suspend fun removeAllScenes( + groupID: UShort, + timedInvokeTimeoutMs: Int? = null + ): RemoveAllScenesResponse { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + tlvReader.exitContainer() + + return RemoveAllScenesResponse(status_decoded, groupID_decoded) + } + + suspend fun storeScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeoutMs: Int? = null + ): StoreSceneResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_SCENE_I_D: Int = 2 + var sceneID_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (sceneID_decoded == null) { + throw IllegalStateException("sceneID not found in TLV") + } + + tlvReader.exitContainer() + + return StoreSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + } + + suspend fun recallScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UShort?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + transitionTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getSceneMembership( + groupID: UShort, + timedInvokeTimeoutMs: Int? = null + ): GetSceneMembershipResponse { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_CAPACITY: Int = 1 + var capacity_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 2 + var groupID_decoded: UShort? = null + + val TAG_SCENE_LIST: Int = 3 + var sceneList_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_CAPACITY)) { + capacity_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_LIST)) { + sceneList_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + tlvReader.exitContainer() + + return GetSceneMembershipResponse( + status_decoded, + capacity_decoded, + groupID_decoded, + sceneList_decoded + ) + } + + suspend fun enhancedAddScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UShort, + sceneName: String, + extensionFieldSets: List, + timedInvokeTimeoutMs: Int? = null + ): EnhancedAddSceneResponse { + val commandId: UInt = 64u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + + val TAG_TRANSITION_TIME_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + + val TAG_SCENE_NAME_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_NAME_REQ), sceneName) + + val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 + tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_SCENE_I_D: Int = 2 + var sceneID_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (sceneID_decoded == null) { + throw IllegalStateException("sceneID not found in TLV") + } + + tlvReader.exitContainer() + + return EnhancedAddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + } + + suspend fun enhancedViewScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeoutMs: Int? = null + ): EnhancedViewSceneResponse { + val commandId: UInt = 65u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_GROUP_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + + val TAG_SCENE_I_D_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_I_D: Int = 1 + var groupID_decoded: UShort? = null + + val TAG_SCENE_I_D: Int = 2 + var sceneID_decoded: UByte? = null + + val TAG_TRANSITION_TIME: Int = 3 + var transitionTime_decoded: UShort? = null + + val TAG_SCENE_NAME: Int = 4 + var sceneName_decoded: String? = null + + val TAG_EXTENSION_FIELD_SETS: Int = 5 + var extensionFieldSets_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { + transitionTime_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { + sceneName_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { + extensionFieldSets_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupID_decoded == null) { + throw IllegalStateException("groupID not found in TLV") + } + + if (sceneID_decoded == null) { + throw IllegalStateException("sceneID not found in TLV") + } + + tlvReader.exitContainer() + + return EnhancedViewSceneResponse( + status_decoded, + groupID_decoded, + sceneID_decoded, + transitionTime_decoded, + sceneName_decoded, + extensionFieldSets_decoded + ) + } + + suspend fun copyScene( + mode: UByte, + groupIdentifierFrom: UShort, + sceneIdentifierFrom: UByte, + groupIdentifierTo: UShort, + sceneIdentifierTo: UByte, + timedInvokeTimeoutMs: Int? = null + ): CopySceneResponse { + val commandId: UInt = 66u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MODE_REQ), mode) + + val TAG_GROUP_IDENTIFIER_FROM_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM_REQ), groupIdentifierFrom) + + val TAG_SCENE_IDENTIFIER_FROM_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM_REQ), sceneIdentifierFrom) + + val TAG_GROUP_IDENTIFIER_TO_REQ: Int = 3 + tlvWriter.put(ContextSpecificTag(TAG_GROUP_IDENTIFIER_TO_REQ), groupIdentifierTo) + + val TAG_SCENE_IDENTIFIER_TO_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_GROUP_IDENTIFIER_FROM: Int = 1 + var groupIdentifierFrom_decoded: UShort? = null + + val TAG_SCENE_IDENTIFIER_FROM: Int = 2 + var sceneIdentifierFrom_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) { + groupIdentifierFrom_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) { + sceneIdentifierFrom_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + if (groupIdentifierFrom_decoded == null) { + throw IllegalStateException("groupIdentifierFrom not found in TLV") + } + + if (sceneIdentifierFrom_decoded == null) { + throw IllegalStateException("sceneIdentifierFrom not found in TLV") + } + + tlvReader.exitContainer() + + return CopySceneResponse( + status_decoded, + groupIdentifierFrom_decoded, + sceneIdentifierFrom_decoded + ) + } + + suspend fun readSceneCountAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scenecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentSceneAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentscene attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentGroupAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentgroup attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSceneValidAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scenevalid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNameSupportAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Namesupport attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Lastconfiguredby attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LastConfiguredByAttribute(decodedValue) + } + + suspend fun readSceneTableSizeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Scenetablesize attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Fabricsceneinfo attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return FabricSceneInfoAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ScenesCluster::class.java.name) + const val CLUSTER_ID: UInt = 5u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt new file mode 100644 index 00000000000000..5d0bbf0a702302 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt @@ -0,0 +1,773 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SmokeCoAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun selfTestRequest(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readExpressedStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Expressedstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readSmokeStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Smokestate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCOStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Costate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBatteryAlertAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Batteryalert attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readDeviceMutedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Devicemuted attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTestInProgressAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Testinprogress attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readHardwareFaultAlertAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hardwarefaultalert attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun readEndOfServiceAlertAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Endofservicealert attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readInterconnectSmokeAlarmAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Interconnectsmokealarm attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInterconnectCOAlarmAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Interconnectcoalarm attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readContaminationStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Contaminationstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSmokeSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Smokesensitivitylevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeSmokeSensitivityLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 11u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readExpiryDateAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Expirydate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(SmokeCoAlarmCluster::class.java.name) + const val CLUSTER_ID: UInt = 92u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt new file mode 100644 index 00000000000000..7726983ed52b47 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt @@ -0,0 +1,437 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SoftwareDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ThreadMetricsAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun resetWatermarks(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Threadmetrics attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return ThreadMetricsAttribute(decodedValue) + } + + suspend fun readCurrentHeapFreeAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentheapfree attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentHeapUsedAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentheapused attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentheaphighwatermark attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(SoftwareDiagnosticsCluster::class.java.name) + const val CLUSTER_ID: UInt = 52u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt new file mode 100644 index 00000000000000..d3d4c67012010f --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt @@ -0,0 +1,355 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readNumberOfPositionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofpositions attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readCurrentPositionAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentposition attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readMultiPressMaxAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Multipressmax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(SwitchCluster::class.java.name) + const val CLUSTER_ID: UInt = 59u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt new file mode 100644 index 00000000000000..b528993e51a7e6 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt @@ -0,0 +1,415 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class TargetNavigatorCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NavigateTargetResponse(val status: UByte, val data: String?) + + class TargetListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun navigateTarget( + target: UByte, + data: String?, + timedInvokeTimeoutMs: Int? = null + ): NavigateTargetResponse { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TARGET_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TARGET_REQ), target) + + val TAG_DATA_REQ: Int = 1 + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_STATUS: Int = 0 + var status_decoded: UByte? = null + + val TAG_DATA: Int = 1 + var data_decoded: String? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (status_decoded == null) { + throw IllegalStateException("status not found in TLV") + } + + tlvReader.exitContainer() + + return NavigateTargetResponse(status_decoded, data_decoded) + } + + suspend fun readTargetListAttribute(): TargetListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Targetlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return TargetListAttribute(decodedValue) + } + + suspend fun readCurrentTargetAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currenttarget attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(TargetNavigatorCluster::class.java.name) + const val CLUSTER_ID: UInt = 1285u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt new file mode 100644 index 00000000000000..f6663fee2f8e26 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt @@ -0,0 +1,524 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class TemperatureControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedTemperatureLevelsAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun setTemperature( + targetTemperature: Short?, + targetTemperatureLevel: UByte?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TARGET_TEMPERATURE_REQ: Int = 0 + targetTemperature?.let { + tlvWriter.put(ContextSpecificTag(TAG_TARGET_TEMPERATURE_REQ), targetTemperature) + } + + val TAG_TARGET_TEMPERATURE_LEVEL_REQ: Int = 1 + targetTemperatureLevel?.let { + tlvWriter.put(ContextSpecificTag(TAG_TARGET_TEMPERATURE_LEVEL_REQ), targetTemperatureLevel) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readTemperatureSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Temperaturesetpoint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMinTemperatureAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Mintemperature attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMaxTemperatureAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxtemperature attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readStepAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Step attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSelectedTemperatureLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Selectedtemperaturelevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedtemperaturelevels attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return SupportedTemperatureLevelsAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(TemperatureControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 86u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt new file mode 100644 index 00000000000000..4bf9afee80b853 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt @@ -0,0 +1,413 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class TemperatureMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Short?) + + class MinMeasuredValueAttribute(val value: Short?) + + class MaxMeasuredValueAttribute(val value: Short?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(TemperatureMeasurementCluster::class.java.name) + const val CLUSTER_ID: UInt = 1026u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt new file mode 100644 index 00000000000000..4ab15f65f59b01 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt @@ -0,0 +1,3461 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ThermostatCluster(private val controller: MatterController, private val endpointId: UShort) { + class GetWeeklyScheduleResponse( + val numberOfTransitionsForSequence: UByte, + val dayOfWeekForSequence: UByte, + val modeForSequence: UByte, + val transitions: List + ) + + class LocalTemperatureAttribute(val value: Short?) + + class OutdoorTemperatureAttribute(val value: Short?) + + class TemperatureSetpointHoldDurationAttribute(val value: UShort?) + + class SetpointChangeAmountAttribute(val value: Short?) + + class OccupiedSetbackAttribute(val value: UByte?) + + class OccupiedSetbackMinAttribute(val value: UByte?) + + class OccupiedSetbackMaxAttribute(val value: UByte?) + + class UnoccupiedSetbackAttribute(val value: UByte?) + + class UnoccupiedSetbackMinAttribute(val value: UByte?) + + class UnoccupiedSetbackMaxAttribute(val value: UByte?) + + class ACCoilTemperatureAttribute(val value: Short?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun setpointRaiseLower(mode: UByte, amount: Byte, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_MODE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MODE_REQ), mode) + + val TAG_AMOUNT_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setWeeklySchedule( + numberOfTransitionsForSequence: UByte, + dayOfWeekForSequence: UByte, + modeForSequence: UByte, + transitions: List, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ: Int = 0 + tlvWriter.put( + ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), + numberOfTransitionsForSequence + ) + + val TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ), dayOfWeekForSequence) + + val TAG_MODE_FOR_SEQUENCE_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_MODE_FOR_SEQUENCE_REQ), modeForSequence) + + val TAG_TRANSITIONS_REQ: Int = 3 + tlvWriter.startArray(ContextSpecificTag(TAG_TRANSITIONS_REQ)) + for (item in transitions.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun getWeeklySchedule( + daysToReturn: UByte, + modeToReturn: UByte, + timedInvokeTimeoutMs: Int? = null + ): GetWeeklyScheduleResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DAYS_TO_RETURN_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_DAYS_TO_RETURN_REQ), daysToReturn) + + val TAG_MODE_TO_RETURN_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE: Int = 0 + var numberOfTransitionsForSequence_decoded: UByte? = null + + val TAG_DAY_OF_WEEK_FOR_SEQUENCE: Int = 1 + var dayOfWeekForSequence_decoded: UByte? = null + + val TAG_MODE_FOR_SEQUENCE: Int = 2 + var modeForSequence_decoded: UByte? = null + + val TAG_TRANSITIONS: Int = 3 + var transitions_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) { + numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) { + dayOfWeekForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) { + modeForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITIONS)) { + transitions_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (numberOfTransitionsForSequence_decoded == null) { + throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") + } + + if (dayOfWeekForSequence_decoded == null) { + throw IllegalStateException("dayOfWeekForSequence not found in TLV") + } + + if (modeForSequence_decoded == null) { + throw IllegalStateException("modeForSequence not found in TLV") + } + + if (transitions_decoded == null) { + throw IllegalStateException("transitions not found in TLV") + } + + tlvReader.exitContainer() + + return GetWeeklyScheduleResponse( + numberOfTransitionsForSequence_decoded, + dayOfWeekForSequence_decoded, + modeForSequence_decoded, + transitions_decoded + ) + } + + suspend fun clearWeeklySchedule(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Localtemperature attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LocalTemperatureAttribute(decodedValue) + } + + suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Outdoortemperature attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OutdoorTemperatureAttribute(decodedValue) + } + + suspend fun readOccupancyAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupancy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Absminheatsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Absmaxheatsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Absmincoolsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Absmaxcoolsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPICoolingDemandAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Picoolingdemand attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPIHeatingDemandAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Piheatingdemand attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hvacsystemtypeconfiguration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeHVACSystemTypeConfigurationAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 9u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLocalTemperatureCalibrationAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Localtemperaturecalibration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeLocalTemperatureCalibrationAttribute( + value: Byte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOccupiedCoolingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupiedcoolingsetpoint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOccupiedCoolingSetpointAttribute( + value: Short, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 17u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOccupiedHeatingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupiedheatingsetpoint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeOccupiedHeatingSetpointAttribute( + value: Short, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 18u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Unoccupiedcoolingsetpoint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUnoccupiedCoolingSetpointAttribute( + value: Short, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 19u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Unoccupiedheatingsetpoint attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUnoccupiedHeatingSetpointAttribute( + value: Short, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 20u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readMinHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minheatsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeMinHeatSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 21u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readMaxHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxheatsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeMaxHeatSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 22u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readMinCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Mincoolsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeMinCoolSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 23u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readMaxCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxcoolsetpointlimit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeMaxCoolSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 24u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readMinSetpointDeadBandAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minsetpointdeadband attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeMinSetpointDeadBandAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 25u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRemoteSensingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Remotesensing attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeRemoteSensingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 26u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readControlSequenceOfOperationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Controlsequenceofoperation attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeControlSequenceOfOperationAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 27u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSystemModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Systemmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeSystemModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 28u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readThermostatRunningModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Thermostatrunningmode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readStartOfWeekAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startofweek attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofweeklytransitions attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfDailyTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofdailytransitions attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTemperatureSetpointHoldAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Temperaturesetpointhold attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeTemperatureSetpointHoldAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 35u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readTemperatureSetpointHoldDurationAttribute(): + TemperatureSetpointHoldDurationAttribute { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return TemperatureSetpointHoldDurationAttribute(decodedValue) + } + + suspend fun writeTemperatureSetpointHoldDurationAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 36u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeThermostatProgrammingOperationModeAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 37u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readThermostatRunningStateAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Thermostatrunningstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSetpointChangeSourceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Setpointchangesource attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Setpointchangeamount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SetpointChangeAmountAttribute(decodedValue) + } + + suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupiedsetback attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OccupiedSetbackAttribute(decodedValue) + } + + suspend fun writeOccupiedSetbackAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 52u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupiedsetbackmin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OccupiedSetbackMinAttribute(decodedValue) + } + + suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Occupiedsetbackmax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OccupiedSetbackMaxAttribute(decodedValue) + } + + suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Unoccupiedsetback attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return UnoccupiedSetbackAttribute(decodedValue) + } + + suspend fun writeUnoccupiedSetbackAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 55u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Unoccupiedsetbackmin attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return UnoccupiedSetbackMinAttribute(decodedValue) + } + + suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { + val ATTRIBUTE_ID: UInt = 57u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Unoccupiedsetbackmax attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return UnoccupiedSetbackMaxAttribute(decodedValue) + } + + suspend fun readEmergencyHeatDeltaAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Emergencyheatdelta attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeEmergencyHeatDeltaAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 58u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 64u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Actype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACTypeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 64u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACCapacityAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 65u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accapacity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACCapacityAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 65u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACRefrigerantTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 66u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acrefrigeranttype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACRefrigerantTypeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 66u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACCompressorTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 67u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accompressortype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACCompressorTypeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 67u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACErrorCodeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 68u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acerrorcode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACErrorCodeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 68u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACLouverPositionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 69u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Aclouverposition attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACLouverPositionAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 69u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 70u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accoiltemperature attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ACCoilTemperatureAttribute(decodedValue) + } + + suspend fun readACCapacityformatAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 71u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Accapacityformat attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeACCapacityformatAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 71u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ThermostatCluster::class.java.name) + const val CLUSTER_ID: UInt = 513u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt new file mode 100644 index 00000000000000..a535c7912ace54 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt @@ -0,0 +1,495 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ThermostatUserInterfaceConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readTemperatureDisplayModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Temperaturedisplaymode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeTemperatureDisplayModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readKeypadLockoutAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Keypadlockout attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeKeypadLockoutAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeScheduleProgrammingVisibilityAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) + const val CLUSTER_ID: UInt = 516u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt new file mode 100644 index 00000000000000..0e75d1581d94a6 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt @@ -0,0 +1,2634 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ThreadNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChannelAttribute(val value: UShort?) + + class RoutingRoleAttribute(val value: UByte?) + + class NetworkNameAttribute(val value: String?) + + class PanIdAttribute(val value: UShort?) + + class ExtendedPanIdAttribute(val value: ULong?) + + class MeshLocalPrefixAttribute(val value: ByteArray?) + + class NeighborTableAttribute(val value: List) + + class RouteTableAttribute(val value: List) + + class PartitionIdAttribute(val value: UInt?) + + class WeightingAttribute(val value: UShort?) + + class DataVersionAttribute(val value: UShort?) + + class StableDataVersionAttribute(val value: UShort?) + + class LeaderRouterIdAttribute(val value: UByte?) + + class ActiveTimestampAttribute(val value: ULong?) + + class PendingTimestampAttribute(val value: ULong?) + + class DelayAttribute(val value: UInt?) + + class SecurityPolicyAttribute(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) + + class ChannelPage0MaskAttribute(val value: ByteArray?) + + class OperationalDatasetComponentsAttribute( + val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? + ) + + class ActiveNetworkFaultsListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun resetCounts(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readChannelAttribute(): ChannelAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Channel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ChannelAttribute(decodedValue) + } + + suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Routingrole attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return RoutingRoleAttribute(decodedValue) + } + + suspend fun readNetworkNameAttribute(): NetworkNameAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Networkname attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NetworkNameAttribute(decodedValue) + } + + suspend fun readPanIdAttribute(): PanIdAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Panid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PanIdAttribute(decodedValue) + } + + suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Extendedpanid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ExtendedPanIdAttribute(decodedValue) + } + + suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Meshlocalprefix attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeshLocalPrefixAttribute(decodedValue) + } + + suspend fun readOverrunCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNeighborTableAttribute(): NeighborTableAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Neighbortable attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return NeighborTableAttribute(decodedValue) + } + + suspend fun readRouteTableAttribute(): RouteTableAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Routetable attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return RouteTableAttribute(decodedValue) + } + + suspend fun readPartitionIdAttribute(): PartitionIdAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Partitionid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PartitionIdAttribute(decodedValue) + } + + suspend fun readWeightingAttribute(): WeightingAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Weighting attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return WeightingAttribute(decodedValue) + } + + suspend fun readDataVersionAttribute(): DataVersionAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dataversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DataVersionAttribute(decodedValue) + } + + suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Stabledataversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return StableDataVersionAttribute(decodedValue) + } + + suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Leaderrouterid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LeaderRouterIdAttribute(decodedValue) + } + + suspend fun readDetachedRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Detachedrolecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readChildRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Childrolecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRouterRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Routerrolecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLeaderRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Leaderrolecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAttachAttemptCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attachattemptcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPartitionIdChangeCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Partitionidchangecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readParentChangeCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Parentchangecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxTotalCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txtotalcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxUnicastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txunicastcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxBroadcastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txbroadcastcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxAckRequestedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txackrequestedcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxAckedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txackedcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxNoAckRequestedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txnoackrequestedcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxDataCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txdatacount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxDataPollCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txdatapollcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxBeaconCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txbeaconcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxBeaconRequestCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txbeaconrequestcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txothercount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxRetryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txretrycount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txdirectmaxretryexpirycount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxErrCcaCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txerrccacount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxErrAbortCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txerrabortcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTxErrBusyChannelCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Txerrbusychannelcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxTotalCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxtotalcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxUnicastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxunicastcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxBroadcastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxbroadcastcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxDataCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxdatacount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxDataPollCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxdatapollcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxBeaconCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 44u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxbeaconcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxBeaconRequestCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 45u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxbeaconrequestcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 46u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxothercount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxAddressFilteredCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 47u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxaddressfilteredcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxDestAddrFilteredCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxdestaddrfilteredcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxDuplicatedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxduplicatedcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxErrNoFrameCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxerrnoframecount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxerrunknownneighborcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxerrinvalidsrcaddrcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxErrSecCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxerrseccount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxErrFcsCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxerrfcscount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readRxErrOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rxerrothercount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activetimestamp attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ActiveTimestampAttribute(decodedValue) + } + + suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute { + val ATTRIBUTE_ID: UInt = 57u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Pendingtimestamp attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PendingTimestampAttribute(decodedValue) + } + + suspend fun readDelayAttribute(): DelayAttribute { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Delay attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DelayAttribute(decodedValue) + } + + suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute { + val ATTRIBUTE_ID: UInt = 59u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Securitypolicy attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SecurityPolicyAttribute(decodedValue) + } + + suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute { + val ATTRIBUTE_ID: UInt = 60u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Channelpage0mask attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ChannelPage0MaskAttribute(decodedValue) + } + + suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute { + val ATTRIBUTE_ID: UInt = 61u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationaldatasetcomponents attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OperationalDatasetComponentsAttribute(decodedValue) + } + + suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute { + val ATTRIBUTE_ID: UInt = 62u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activenetworkfaultslist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return ActiveNetworkFaultsListAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ThreadNetworkDiagnosticsCluster::class.java.name) + const val CLUSTER_ID: UInt = 53u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt new file mode 100644 index 00000000000000..a94ae87a98ae2e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt @@ -0,0 +1,460 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class TimeFormatLocalizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedCalendarTypesAttribute(val value: List?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readHourFormatAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Hourformat attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeHourFormatAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readActiveCalendarTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Activecalendartype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeActiveCalendarTypeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportedcalendartypes attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return SupportedCalendarTypesAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(TimeFormatLocalizationCluster::class.java.name) + const val CLUSTER_ID: UInt = 44u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt new file mode 100644 index 00000000000000..8ad5b457803684 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt @@ -0,0 +1,940 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class TimeSynchronizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SetTimeZoneResponse(val DSTOffsetRequired: Boolean) + + class UTCTimeAttribute(val value: ULong?) + + class TrustedTimeSourceAttribute(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) + + class DefaultNTPAttribute(val value: String?) + + class TimeZoneAttribute(val value: List?) + + class DSTOffsetAttribute(val value: List?) + + class LocalTimeAttribute(val value: ULong?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun setUTCTime( + UTCTime: ULong, + granularity: UByte, + timeSource: UByte?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_U_T_C_TIME_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_U_T_C_TIME_REQ), UTCTime) + + val TAG_GRANULARITY_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_GRANULARITY_REQ), granularity) + + val TAG_TIME_SOURCE_REQ: Int = 2 + timeSource?.let { tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setTrustedTimeSource( + trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct?, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TRUSTED_TIME_SOURCE_REQ: Int = 0 + trustedTimeSource?.let { + trustedTimeSource.toTlv(ContextSpecificTag(TAG_TRUSTED_TIME_SOURCE_REQ), tlvWriter) + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setTimeZone( + timeZone: List, + timedInvokeTimeoutMs: Int? = null + ): SetTimeZoneResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TIME_ZONE_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_TIME_ZONE_REQ)) + for (item in timeZone.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_D_S_T_OFFSET_REQUIRED: Int = 0 + var DSTOffsetRequired_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) { + DSTOffsetRequired_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (DSTOffsetRequired_decoded == null) { + throw IllegalStateException("DSTOffsetRequired not found in TLV") + } + + tlvReader.exitContainer() + + return SetTimeZoneResponse(DSTOffsetRequired_decoded) + } + + suspend fun setDSTOffset( + DSTOffset: List, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_D_S_T_OFFSET_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_D_S_T_OFFSET_REQ)) + for (item in DSTOffset.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setDefaultNTP(defaultNTP: String?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_DEFAULT_N_T_P_REQ: Int = 0 + defaultNTP?.let { tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readUTCTimeAttribute(): UTCTimeAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Utctime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return UTCTimeAttribute(decodedValue) + } + + suspend fun readGranularityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Granularity attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readTimeSourceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timesource attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Trustedtimesource attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return TrustedTimeSourceAttribute(decodedValue) + } + + suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Defaultntp attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return DefaultNTPAttribute(decodedValue) + } + + suspend fun readTimeZoneAttribute(): TimeZoneAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timezone attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return TimeZoneAttribute(decodedValue) + } + + suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dstoffset attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + return DSTOffsetAttribute(decodedValue) + } + + suspend fun readLocalTimeAttribute(): LocalTimeAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Localtime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return LocalTimeAttribute(decodedValue) + } + + suspend fun readTimeZoneDatabaseAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timezonedatabase attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNTPServerAvailableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Ntpserveravailable attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readTimeZoneListMaxSizeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timezonelistmaxsize attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Dstoffsetlistmaxsize attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readSupportsDNSResolveAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Supportsdnsresolve attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(TimeSynchronizationCluster::class.java.name) + const val CLUSTER_ID: UInt = 56u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt new file mode 100644 index 00000000000000..9a200d28b3cb26 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt @@ -0,0 +1,445 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class TimerCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun setTimer(newTime: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NEW_TIME_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun resetTimer(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun addTime(additionalTime: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ADDITIONAL_TIME_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun reduceTime(timeReduction: UInt, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TIME_REDUCTION_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readSetTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Settime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readTimeRemainingAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timeremaining attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readTimerStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timerstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(TimerCluster::class.java.name) + const val CLUSTER_ID: UInt = 71u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt new file mode 100644 index 00000000000000..e5b5378056b324 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt @@ -0,0 +1,694 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) + + class MinMeasuredValueAttribute(val value: Float?) + + class MaxMeasuredValueAttribute(val value: Float?) + + class PeakMeasuredValueAttribute(val value: Float?) + + class AverageMeasuredValueAttribute(val value: Float?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MeasuredValueAttribute(decodedValue) + } + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MinMeasuredValueAttribute(decodedValue) + } + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return MaxMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PeakMeasuredValueAttribute(decodedValue) + } + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AverageMeasuredValueAttribute(decodedValue) + } + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = + Logger.getLogger( + TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name + ) + const val CLUSTER_ID: UInt = 1070u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt new file mode 100644 index 00000000000000..75cd20f19e793a --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt @@ -0,0 +1,343 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class UnitLocalizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readTemperatureUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Temperatureunit attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeTemperatureUnitAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(UnitLocalizationCluster::class.java.name) + const val CLUSTER_ID: UInt = 45u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt new file mode 100644 index 00000000000000..c0bd70eb10c1f0 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt @@ -0,0 +1,8415 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class UnitTestingCluster(private val controller: MatterController, private val endpointId: UShort) { + class TestSpecificResponse(val returnValue: UByte) + + class TestAddArgumentsResponse(val returnValue: UByte) + + class TestSimpleArgumentResponse(val returnValue: Boolean) + + class TestStructArrayArgumentResponse( + val arg1: List, + val arg2: List, + val arg3: List, + val arg4: List, + val arg5: UByte, + val arg6: Boolean + ) + + class BooleanResponse(val value: Boolean) + + class TestListInt8UReverseResponse(val arg1: List) + + class TestEnumsResponse(val arg1: UShort, val arg2: UByte) + + class TestNullableOptionalResponse( + val wasPresent: Boolean, + val wasNull: Boolean?, + val value: UByte?, + val originalValue: UByte? + ) + + class TestComplexNullableOptionalResponse( + val nullableIntWasNull: Boolean, + val nullableIntValue: UShort?, + val optionalIntWasPresent: Boolean, + val optionalIntValue: UShort?, + val nullableOptionalIntWasPresent: Boolean, + val nullableOptionalIntWasNull: Boolean?, + val nullableOptionalIntValue: UShort?, + val nullableStringWasNull: Boolean, + val nullableStringValue: String?, + val optionalStringWasPresent: Boolean, + val optionalStringValue: String?, + val nullableOptionalStringWasPresent: Boolean, + val nullableOptionalStringWasNull: Boolean?, + val nullableOptionalStringValue: String?, + val nullableStructWasNull: Boolean, + val nullableStructValue: UnitTestingClusterSimpleStruct?, + val optionalStructWasPresent: Boolean, + val optionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableOptionalStructWasPresent: Boolean, + val nullableOptionalStructWasNull: Boolean?, + val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableListWasNull: Boolean, + val nullableListValue: List?, + val optionalListWasPresent: Boolean, + val optionalListValue: List?, + val nullableOptionalListWasPresent: Boolean, + val nullableOptionalListWasNull: Boolean?, + val nullableOptionalListValue: List? + ) + + class SimpleStructResponse(val arg1: UnitTestingClusterSimpleStruct) + + class TestEmitTestEventResponse(val value: ULong) + + class TestEmitTestFabricScopedEventResponse(val value: ULong) + + class ListInt8uAttribute(val value: List) + + class ListOctetStringAttribute(val value: List) + + class ListStructOctetStringAttribute(val value: List) + + class ListNullablesAndOptionalsStructAttribute( + val value: List + ) + + class StructAttrAttribute(val value: UnitTestingClusterSimpleStruct) + + class ListLongOctetStringAttribute(val value: List) + + class ListFabricScopedAttribute(val value: List) + + class NullableBooleanAttribute(val value: Boolean?) + + class NullableBitmap8Attribute(val value: UByte?) + + class NullableBitmap16Attribute(val value: UShort?) + + class NullableBitmap32Attribute(val value: UInt?) + + class NullableBitmap64Attribute(val value: ULong?) + + class NullableInt8uAttribute(val value: UByte?) + + class NullableInt16uAttribute(val value: UShort?) + + class NullableInt24uAttribute(val value: UInt?) + + class NullableInt32uAttribute(val value: UInt?) + + class NullableInt40uAttribute(val value: ULong?) + + class NullableInt48uAttribute(val value: ULong?) + + class NullableInt56uAttribute(val value: ULong?) + + class NullableInt64uAttribute(val value: ULong?) + + class NullableInt8sAttribute(val value: Byte?) + + class NullableInt16sAttribute(val value: Short?) + + class NullableInt24sAttribute(val value: Int?) + + class NullableInt32sAttribute(val value: Int?) + + class NullableInt40sAttribute(val value: Long?) + + class NullableInt48sAttribute(val value: Long?) + + class NullableInt56sAttribute(val value: Long?) + + class NullableInt64sAttribute(val value: Long?) + + class NullableEnum8Attribute(val value: UByte?) + + class NullableEnum16Attribute(val value: UShort?) + + class NullableFloatSingleAttribute(val value: Float?) + + class NullableFloatDoubleAttribute(val value: Double?) + + class NullableOctetStringAttribute(val value: ByteArray?) + + class NullableCharStringAttribute(val value: String?) + + class NullableEnumAttrAttribute(val value: UByte?) + + class NullableStructAttribute(val value: UnitTestingClusterSimpleStruct?) + + class NullableRangeRestrictedInt8uAttribute(val value: UByte?) + + class NullableRangeRestrictedInt8sAttribute(val value: Byte?) + + class NullableRangeRestrictedInt16uAttribute(val value: UShort?) + + class NullableRangeRestrictedInt16sAttribute(val value: Short?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun test(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun testNotHandled(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun testSpecific(timedInvokeTimeoutMs: Int? = null): TestSpecificResponse { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_RETURN_VALUE: Int = 0 + var returnValue_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (returnValue_decoded == null) { + throw IllegalStateException("returnValue not found in TLV") + } + + tlvReader.exitContainer() + + return TestSpecificResponse(returnValue_decoded) + } + + suspend fun testUnknownCommand(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 3u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun testAddArguments( + arg1: UByte, + arg2: UByte, + timedInvokeTimeoutMs: Int? = null + ): TestAddArgumentsResponse { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + + val TAG_ARG2_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_RETURN_VALUE: Int = 0 + var returnValue_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (returnValue_decoded == null) { + throw IllegalStateException("returnValue not found in TLV") + } + + tlvReader.exitContainer() + + return TestAddArgumentsResponse(returnValue_decoded) + } + + suspend fun testSimpleArgumentRequest( + arg1: Boolean, + timedInvokeTimeoutMs: Int? = null + ): TestSimpleArgumentResponse { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_RETURN_VALUE: Int = 0 + var returnValue_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (returnValue_decoded == null) { + throw IllegalStateException("returnValue not found in TLV") + } + + tlvReader.exitContainer() + + return TestSimpleArgumentResponse(returnValue_decoded) + } + + suspend fun testStructArrayArgumentRequest( + arg1: List, + arg2: List, + arg3: List, + arg4: List, + arg5: UByte, + arg6: Boolean, + timedInvokeTimeoutMs: Int? = null + ): TestStructArrayArgumentResponse { + val commandId: UInt = 6u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val TAG_ARG2_REQ: Int = 1 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG2_REQ)) + for (item in arg2.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val TAG_ARG3_REQ: Int = 2 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG3_REQ)) + for (item in arg3.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + + val TAG_ARG4_REQ: Int = 3 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG4_REQ)) + for (item in arg4.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + + val TAG_ARG5_REQ: Int = 4 + tlvWriter.put(ContextSpecificTag(TAG_ARG5_REQ), arg5) + + val TAG_ARG6_REQ: Int = 5 + tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ARG1: Int = 0 + var arg1_decoded: List? = null + + val TAG_ARG2: Int = 1 + var arg2_decoded: List? = null + + val TAG_ARG3: Int = 2 + var arg3_decoded: List? = null + + val TAG_ARG4: Int = 3 + var arg4_decoded: List? = null + + val TAG_ARG5: Int = 4 + var arg5_decoded: UByte? = null + + val TAG_ARG6: Int = 5 + var arg6_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG2)) { + arg2_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG3)) { + arg3_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG4)) { + arg4_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getBoolean(AnonymousTag)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG5)) { + arg5_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_ARG6)) { + arg6_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (arg1_decoded == null) { + throw IllegalStateException("arg1 not found in TLV") + } + + if (arg2_decoded == null) { + throw IllegalStateException("arg2 not found in TLV") + } + + if (arg3_decoded == null) { + throw IllegalStateException("arg3 not found in TLV") + } + + if (arg4_decoded == null) { + throw IllegalStateException("arg4 not found in TLV") + } + + if (arg5_decoded == null) { + throw IllegalStateException("arg5 not found in TLV") + } + + if (arg6_decoded == null) { + throw IllegalStateException("arg6 not found in TLV") + } + + tlvReader.exitContainer() + + return TestStructArrayArgumentResponse( + arg1_decoded, + arg2_decoded, + arg3_decoded, + arg4_decoded, + arg5_decoded, + arg6_decoded + ) + } + + suspend fun testStructArgumentRequest( + arg1: UnitTestingClusterSimpleStruct, + timedInvokeTimeoutMs: Int? = null + ): BooleanResponse { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return BooleanResponse(value_decoded) + } + + suspend fun testNestedStructArgumentRequest( + arg1: UnitTestingClusterNestedStruct, + timedInvokeTimeoutMs: Int? = null + ): BooleanResponse { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return BooleanResponse(value_decoded) + } + + suspend fun testListStructArgumentRequest( + arg1: List, + timedInvokeTimeoutMs: Int? = null + ): BooleanResponse { + val commandId: UInt = 9u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return BooleanResponse(value_decoded) + } + + suspend fun testListInt8UArgumentRequest( + arg1: List, + timedInvokeTimeoutMs: Int? = null + ): BooleanResponse { + val commandId: UInt = 10u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return BooleanResponse(value_decoded) + } + + suspend fun testNestedStructListArgumentRequest( + arg1: UnitTestingClusterNestedStructList, + timedInvokeTimeoutMs: Int? = null + ): BooleanResponse { + val commandId: UInt = 11u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return BooleanResponse(value_decoded) + } + + suspend fun testListNestedStructListArgumentRequest( + arg1: List, + timedInvokeTimeoutMs: Int? = null + ): BooleanResponse { + val commandId: UInt = 12u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: Boolean? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return BooleanResponse(value_decoded) + } + + suspend fun testListInt8UReverseRequest( + arg1: List, + timedInvokeTimeoutMs: Int? = null + ): TestListInt8UReverseResponse { + val commandId: UInt = 13u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ARG1: Int = 0 + var arg1_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (arg1_decoded == null) { + throw IllegalStateException("arg1 not found in TLV") + } + + tlvReader.exitContainer() + + return TestListInt8UReverseResponse(arg1_decoded) + } + + suspend fun testEnumsRequest( + arg1: UShort, + arg2: UByte, + timedInvokeTimeoutMs: Int? = null + ): TestEnumsResponse { + val commandId: UInt = 14u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + + val TAG_ARG2_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ARG1: Int = 0 + var arg1_decoded: UShort? = null + + val TAG_ARG2: Int = 1 + var arg2_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_ARG2)) { + arg2_decoded = tlvReader.getUByte(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (arg1_decoded == null) { + throw IllegalStateException("arg1 not found in TLV") + } + + if (arg2_decoded == null) { + throw IllegalStateException("arg2 not found in TLV") + } + + tlvReader.exitContainer() + + return TestEnumsResponse(arg1_decoded, arg2_decoded) + } + + suspend fun testNullableOptionalRequest( + arg1: UByte?, + timedInvokeTimeoutMs: Int? = null + ): TestNullableOptionalResponse { + val commandId: UInt = 15u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_WAS_PRESENT: Int = 0 + var wasPresent_decoded: Boolean? = null + + val TAG_WAS_NULL: Int = 1 + var wasNull_decoded: Boolean? = null + + val TAG_VALUE: Int = 2 + var value_decoded: UByte? = null + + val TAG_ORIGINAL_VALUE: Int = 3 + var originalValue_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) { + wasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_WAS_NULL)) { + wasNull_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) { + originalValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } else { + tlvReader.getNull(tag) + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (wasPresent_decoded == null) { + throw IllegalStateException("wasPresent not found in TLV") + } + + tlvReader.exitContainer() + + return TestNullableOptionalResponse( + wasPresent_decoded, + wasNull_decoded, + value_decoded, + originalValue_decoded + ) + } + + suspend fun testComplexNullableOptionalRequest( + nullableInt: UShort?, + optionalInt: UShort?, + nullableOptionalInt: UShort?, + nullableString: String?, + optionalString: String?, + nullableOptionalString: String?, + nullableStruct: UnitTestingClusterSimpleStruct?, + optionalStruct: UnitTestingClusterSimpleStruct?, + nullableOptionalStruct: UnitTestingClusterSimpleStruct?, + nullableList: List?, + optionalList: List?, + nullableOptionalList: List?, + timedInvokeTimeoutMs: Int? = null + ): TestComplexNullableOptionalResponse { + val commandId: UInt = 16u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_NULLABLE_INT_REQ: Int = 0 + nullableInt?.let { tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) } + + val TAG_OPTIONAL_INT_REQ: Int = 1 + optionalInt?.let { tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) } + + val TAG_NULLABLE_OPTIONAL_INT_REQ: Int = 2 + nullableOptionalInt?.let { + tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_REQ), nullableOptionalInt) + } + + val TAG_NULLABLE_STRING_REQ: Int = 3 + nullableString?.let { + tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_STRING_REQ), nullableString) + } + + val TAG_OPTIONAL_STRING_REQ: Int = 4 + optionalString?.let { + tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_STRING_REQ), optionalString) + } + + val TAG_NULLABLE_OPTIONAL_STRING_REQ: Int = 5 + nullableOptionalString?.let { + tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_REQ), nullableOptionalString) + } + + val TAG_NULLABLE_STRUCT_REQ: Int = 6 + nullableStruct?.let { + nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT_REQ), tlvWriter) + } + + val TAG_OPTIONAL_STRUCT_REQ: Int = 7 + optionalStruct?.let { + optionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT_REQ), tlvWriter) + } + + val TAG_NULLABLE_OPTIONAL_STRUCT_REQ: Int = 8 + nullableOptionalStruct?.let { + nullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_REQ), tlvWriter) + } + + val TAG_NULLABLE_LIST_REQ: Int = 9 + nullableList?.let { + tlvWriter.startArray(ContextSpecificTag(TAG_NULLABLE_LIST_REQ)) + for (item in nullableList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + } + + val TAG_OPTIONAL_LIST_REQ: Int = 10 + optionalList?.let { + tlvWriter.startArray(ContextSpecificTag(TAG_OPTIONAL_LIST_REQ)) + for (item in optionalList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + } + + val TAG_NULLABLE_OPTIONAL_LIST_REQ: Int = 11 + nullableOptionalList?.let { + tlvWriter.startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_REQ)) + for (item in nullableOptionalList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_NULLABLE_INT_WAS_NULL: Int = 0 + var nullableIntWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_INT_VALUE: Int = 1 + var nullableIntValue_decoded: UShort? = null + + val TAG_OPTIONAL_INT_WAS_PRESENT: Int = 2 + var optionalIntWasPresent_decoded: Boolean? = null + + val TAG_OPTIONAL_INT_VALUE: Int = 3 + var optionalIntValue_decoded: UShort? = null + + val TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT: Int = 4 + var nullableOptionalIntWasPresent_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_INT_WAS_NULL: Int = 5 + var nullableOptionalIntWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_INT_VALUE: Int = 6 + var nullableOptionalIntValue_decoded: UShort? = null + + val TAG_NULLABLE_STRING_WAS_NULL: Int = 7 + var nullableStringWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_STRING_VALUE: Int = 8 + var nullableStringValue_decoded: String? = null + + val TAG_OPTIONAL_STRING_WAS_PRESENT: Int = 9 + var optionalStringWasPresent_decoded: Boolean? = null + + val TAG_OPTIONAL_STRING_VALUE: Int = 10 + var optionalStringValue_decoded: String? = null + + val TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT: Int = 11 + var nullableOptionalStringWasPresent_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL: Int = 12 + var nullableOptionalStringWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_STRING_VALUE: Int = 13 + var nullableOptionalStringValue_decoded: String? = null + + val TAG_NULLABLE_STRUCT_WAS_NULL: Int = 14 + var nullableStructWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_STRUCT_VALUE: Int = 15 + var nullableStructValue_decoded: UnitTestingClusterSimpleStruct? = null + + val TAG_OPTIONAL_STRUCT_WAS_PRESENT: Int = 16 + var optionalStructWasPresent_decoded: Boolean? = null + + val TAG_OPTIONAL_STRUCT_VALUE: Int = 17 + var optionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null + + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT: Int = 18 + var nullableOptionalStructWasPresent_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL: Int = 19 + var nullableOptionalStructWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_STRUCT_VALUE: Int = 20 + var nullableOptionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null + + val TAG_NULLABLE_LIST_WAS_NULL: Int = 21 + var nullableListWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_LIST_VALUE: Int = 22 + var nullableListValue_decoded: List? = null + + val TAG_OPTIONAL_LIST_WAS_PRESENT: Int = 23 + var optionalListWasPresent_decoded: Boolean? = null + + val TAG_OPTIONAL_LIST_VALUE: Int = 24 + var optionalListValue_decoded: List? = null + + val TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT: Int = 25 + var nullableOptionalListWasPresent_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL: Int = 26 + var nullableOptionalListWasNull_decoded: Boolean? = null + + val TAG_NULLABLE_OPTIONAL_LIST_VALUE: Int = 27 + var nullableOptionalListValue_decoded: List? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) { + nullableIntWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) { + nullableIntValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) { + optionalIntWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) { + optionalIntValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) { + nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) { + nullableOptionalIntWasNull_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) { + nullableOptionalIntValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) { + nullableStringWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) { + nullableStringValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) { + optionalStringWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) { + optionalStringValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) { + nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) { + nullableOptionalStringWasNull_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) { + nullableOptionalStringValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) { + nullableStructWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) { + nullableStructValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) { + optionalStructWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) { + optionalStructValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) { + nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) { + nullableOptionalStructWasNull_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) { + nullableOptionalStructValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) { + nullableListWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) { + nullableListValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) { + optionalListWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) { + optionalListValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) { + nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) { + nullableOptionalListWasNull_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) { + nullableOptionalListValue_decoded = + if (tlvReader.isNull()) { + tlvReader.getNull(tag) + null + } else { + if (tlvReader.isNextTag(tag)) { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (nullableIntWasNull_decoded == null) { + throw IllegalStateException("nullableIntWasNull not found in TLV") + } + + if (optionalIntWasPresent_decoded == null) { + throw IllegalStateException("optionalIntWasPresent not found in TLV") + } + + if (nullableOptionalIntWasPresent_decoded == null) { + throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") + } + + if (nullableStringWasNull_decoded == null) { + throw IllegalStateException("nullableStringWasNull not found in TLV") + } + + if (optionalStringWasPresent_decoded == null) { + throw IllegalStateException("optionalStringWasPresent not found in TLV") + } + + if (nullableOptionalStringWasPresent_decoded == null) { + throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") + } + + if (nullableStructWasNull_decoded == null) { + throw IllegalStateException("nullableStructWasNull not found in TLV") + } + + if (optionalStructWasPresent_decoded == null) { + throw IllegalStateException("optionalStructWasPresent not found in TLV") + } + + if (nullableOptionalStructWasPresent_decoded == null) { + throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") + } + + if (nullableListWasNull_decoded == null) { + throw IllegalStateException("nullableListWasNull not found in TLV") + } + + if (optionalListWasPresent_decoded == null) { + throw IllegalStateException("optionalListWasPresent not found in TLV") + } + + if (nullableOptionalListWasPresent_decoded == null) { + throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") + } + + tlvReader.exitContainer() + + return TestComplexNullableOptionalResponse( + nullableIntWasNull_decoded, + nullableIntValue_decoded, + optionalIntWasPresent_decoded, + optionalIntValue_decoded, + nullableOptionalIntWasPresent_decoded, + nullableOptionalIntWasNull_decoded, + nullableOptionalIntValue_decoded, + nullableStringWasNull_decoded, + nullableStringValue_decoded, + optionalStringWasPresent_decoded, + optionalStringValue_decoded, + nullableOptionalStringWasPresent_decoded, + nullableOptionalStringWasNull_decoded, + nullableOptionalStringValue_decoded, + nullableStructWasNull_decoded, + nullableStructValue_decoded, + optionalStructWasPresent_decoded, + optionalStructValue_decoded, + nullableOptionalStructWasPresent_decoded, + nullableOptionalStructWasNull_decoded, + nullableOptionalStructValue_decoded, + nullableListWasNull_decoded, + nullableListValue_decoded, + optionalListWasPresent_decoded, + optionalListValue_decoded, + nullableOptionalListWasPresent_decoded, + nullableOptionalListWasNull_decoded, + nullableOptionalListValue_decoded + ) + } + + suspend fun simpleStructEchoRequest( + arg1: UnitTestingClusterSimpleStruct, + timedInvokeTimeoutMs: Int? = null + ): SimpleStructResponse { + val commandId: UInt = 17u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_ARG1: Int = 0 + var arg1_decoded: UnitTestingClusterSimpleStruct? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (arg1_decoded == null) { + throw IllegalStateException("arg1 not found in TLV") + } + + tlvReader.exitContainer() + + return SimpleStructResponse(arg1_decoded) + } + + suspend fun timedInvokeRequest(timedInvokeTimeoutMs: Int) { + val commandId: UInt = 18u + val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun testSimpleOptionalArgumentRequest(arg1: Boolean?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 19u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun testEmitTestEventRequest( + arg1: UByte, + arg2: UByte, + arg3: Boolean, + timedInvokeTimeoutMs: Int? = null + ): TestEmitTestEventResponse { + val commandId: UInt = 20u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + + val TAG_ARG2_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + + val TAG_ARG3_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: ULong? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getULong(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return TestEmitTestEventResponse(value_decoded) + } + + suspend fun testEmitTestFabricScopedEventRequest( + arg1: UByte, + timedInvokeTimeoutMs: Int? = null + ): TestEmitTestFabricScopedEventResponse { + val commandId: UInt = 21u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_ARG1_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_VALUE: Int = 0 + var value_decoded: ULong? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getULong(tag) + } else { + // Skip unknown tags + tlvReader.skipElement() + } + } + + if (value_decoded == null) { + throw IllegalStateException("value not found in TLV") + } + + tlvReader.exitContainer() + + return TestEmitTestFabricScopedEventResponse(value_decoded) + } + + suspend fun readBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Boolean attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBitmap8Attribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Bitmap8 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeBitmap8Attribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 1u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBitmap16Attribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Bitmap16 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeBitmap16Attribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 2u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBitmap32Attribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Bitmap32 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeBitmap32Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 3u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readBitmap64Attribute(): ULong { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Bitmap64 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeBitmap64Attribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 4u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int8u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt16uAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int16u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt16uAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 6u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt24uAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int24u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt24uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 7u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt32uAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int32u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt32uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 8u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt40uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int40u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt40uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 9u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt48uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int48u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt48uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 10u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt56uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int56u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt56uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 11u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt64uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int64u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt64uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 12u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt8sAttribute(): Byte { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int8s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte = tlvReader.getByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt8sAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 13u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt16sAttribute(): Short { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int16s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short = tlvReader.getShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt16sAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 14u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt24sAttribute(): Int { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int24s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int = tlvReader.getInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt24sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 15u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt32sAttribute(): Int { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int32s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int = tlvReader.getInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt32sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt40sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int40s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt40sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 17u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt48sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int48s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt48sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 18u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt56sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int56s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt56sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 19u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readInt64sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Int64s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long = tlvReader.getLong(AnonymousTag) + + return decodedValue + } + + suspend fun writeInt64sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 20u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnum8Attribute(): UByte { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enum8 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeEnum8Attribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 21u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnum16Attribute(): UShort { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enum16 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeEnum16Attribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 22u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readFloatSingleAttribute(): Float { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Floatsingle attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float = tlvReader.getFloat(AnonymousTag) + + return decodedValue + } + + suspend fun writeFloatSingleAttribute(value: Float, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 23u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readFloatDoubleAttribute(): Double { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Floatdouble attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Double = tlvReader.getDouble(AnonymousTag) + + return decodedValue + } + + suspend fun writeFloatDoubleAttribute(value: Double, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 24u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readOctetStringAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Octetstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) + + return decodedValue + } + + suspend fun writeOctetStringAttribute(value: ByteArray, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 25u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readListInt8uAttribute(): ListInt8uAttribute { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Listint8u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return ListInt8uAttribute(decodedValue) + } + + suspend fun writeListInt8uAttribute(value: List, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 26u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readListOctetStringAttribute(): ListOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Listoctetstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return ListOctetStringAttribute(decodedValue) + } + + suspend fun writeListOctetStringAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 27u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Liststructoctetstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return ListStructOctetStringAttribute(decodedValue) + } + + suspend fun writeListStructOctetStringAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 28u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLongOctetStringAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Longoctetstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) + + return decodedValue + } + + suspend fun writeLongOctetStringAttribute(value: ByteArray, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 29u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readCharStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Charstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun writeCharStringAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 30u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readLongCharStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Longcharstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String = tlvReader.getString(AnonymousTag) + + return decodedValue + } + + suspend fun writeLongCharStringAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 31u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEpochUsAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Epochus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + + return decodedValue + } + + suspend fun writeEpochUsAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 32u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEpochSAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Epochs attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun writeEpochSAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 33u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readVendorIdAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeVendorIdAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 34u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readListNullablesAndOptionalsStructAttribute(): + ListNullablesAndOptionalsStructAttribute { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return ListNullablesAndOptionalsStructAttribute(decodedValue) + } + + suspend fun writeListNullablesAndOptionalsStructAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 35u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readEnumAttrAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Enumattr attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeEnumAttrAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 36u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readStructAttrAttribute(): StructAttrAttribute { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Structattr attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UnitTestingClusterSimpleStruct = + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + + return StructAttrAttribute(decodedValue) + } + + suspend fun writeStructAttrAttribute( + value: UnitTestingClusterSimpleStruct, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 37u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + value.toTlv(AnonymousTag, tlvWriter) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRangeRestrictedInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rangerestrictedint8u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeRangeRestrictedInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 38u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRangeRestrictedInt8sAttribute(): Byte { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rangerestrictedint8s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte = tlvReader.getByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeRangeRestrictedInt8sAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 39u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRangeRestrictedInt16uAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rangerestrictedint16u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeRangeRestrictedInt16uAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 40u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readRangeRestrictedInt16sAttribute(): Short { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rangerestrictedint16s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short = tlvReader.getShort(AnonymousTag) + + return decodedValue + } + + suspend fun writeRangeRestrictedInt16sAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 41u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Listlongoctetstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return ListLongOctetStringAttribute(decodedValue) + } + + suspend fun writeListLongOctetStringAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 42u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Listfabricscoped attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return ListFabricScopedAttribute(decodedValue) + } + + suspend fun writeListFabricScopedAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 43u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readTimedWriteBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Timedwriteboolean attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeTimedWriteBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int) { + val ATTRIBUTE_ID: UInt = 48u + val timeoutMs: Duration = Duration.ofMillis(timedWriteTimeoutMs.toLong()) + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneralErrorBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generalerrorboolean attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeGeneralErrorBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 49u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readClusterErrorBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clustererrorboolean attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + + return decodedValue + } + + suspend fun writeClusterErrorBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 50u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readUnsupportedAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 255u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Unsupported attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 255u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableboolean attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBooleanAttribute(decodedValue) + } + + suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16384u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablebitmap8 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBitmap8Attribute(decodedValue) + } + + suspend fun writeNullableBitmap8Attribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16385u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablebitmap16 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBitmap16Attribute(decodedValue) + } + + suspend fun writeNullableBitmap16Attribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16386u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablebitmap32 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBitmap32Attribute(decodedValue) + } + + suspend fun writeNullableBitmap32Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16387u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablebitmap64 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBitmap64Attribute(decodedValue) + } + + suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16388u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute { + val ATTRIBUTE_ID: UInt = 16389u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint8u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt8uAttribute(decodedValue) + } + + suspend fun writeNullableInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16389u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute { + val ATTRIBUTE_ID: UInt = 16390u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint16u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt16uAttribute(decodedValue) + } + + suspend fun writeNullableInt16uAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16390u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute { + val ATTRIBUTE_ID: UInt = 16391u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint24u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt24uAttribute(decodedValue) + } + + suspend fun writeNullableInt24uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16391u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute { + val ATTRIBUTE_ID: UInt = 16392u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint32u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt32uAttribute(decodedValue) + } + + suspend fun writeNullableInt32uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16392u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute { + val ATTRIBUTE_ID: UInt = 16393u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint40u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt40uAttribute(decodedValue) + } + + suspend fun writeNullableInt40uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16393u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute { + val ATTRIBUTE_ID: UInt = 16394u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint48u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt48uAttribute(decodedValue) + } + + suspend fun writeNullableInt48uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16394u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute { + val ATTRIBUTE_ID: UInt = 16395u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint56u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt56uAttribute(decodedValue) + } + + suspend fun writeNullableInt56uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16395u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute { + val ATTRIBUTE_ID: UInt = 16396u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint64u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt64uAttribute(decodedValue) + } + + suspend fun writeNullableInt64uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16396u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute { + val ATTRIBUTE_ID: UInt = 16397u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint8s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt8sAttribute(decodedValue) + } + + suspend fun writeNullableInt8sAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16397u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute { + val ATTRIBUTE_ID: UInt = 16398u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint16s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt16sAttribute(decodedValue) + } + + suspend fun writeNullableInt16sAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16398u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute { + val ATTRIBUTE_ID: UInt = 16399u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint24s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt24sAttribute(decodedValue) + } + + suspend fun writeNullableInt24sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16399u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute { + val ATTRIBUTE_ID: UInt = 16400u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint32s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt32sAttribute(decodedValue) + } + + suspend fun writeNullableInt32sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16400u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute { + val ATTRIBUTE_ID: UInt = 16401u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint40s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt40sAttribute(decodedValue) + } + + suspend fun writeNullableInt40sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16401u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute { + val ATTRIBUTE_ID: UInt = 16402u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint48s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt48sAttribute(decodedValue) + } + + suspend fun writeNullableInt48sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16402u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute { + val ATTRIBUTE_ID: UInt = 16403u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint56s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt56sAttribute(decodedValue) + } + + suspend fun writeNullableInt56sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16403u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute { + val ATTRIBUTE_ID: UInt = 16404u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableint64s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableInt64sAttribute(decodedValue) + } + + suspend fun writeNullableInt64sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16404u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute { + val ATTRIBUTE_ID: UInt = 16405u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableenum8 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableEnum8Attribute(decodedValue) + } + + suspend fun writeNullableEnum8Attribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16405u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute { + val ATTRIBUTE_ID: UInt = 16406u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableenum16 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableEnum16Attribute(decodedValue) + } + + suspend fun writeNullableEnum16Attribute(value: UShort, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16406u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute { + val ATTRIBUTE_ID: UInt = 16407u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablefloatsingle attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Float? = + if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableFloatSingleAttribute(decodedValue) + } + + suspend fun writeNullableFloatSingleAttribute(value: Float, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16407u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute { + val ATTRIBUTE_ID: UInt = 16408u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablefloatdouble attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Double? = + if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableFloatDoubleAttribute(decodedValue) + } + + suspend fun writeNullableFloatDoubleAttribute(value: Double, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16408u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 16409u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableoctetstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableOctetStringAttribute(decodedValue) + } + + suspend fun writeNullableOctetStringAttribute( + value: ByteArray, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16409u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute { + val ATTRIBUTE_ID: UInt = 16414u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablecharstring attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableCharStringAttribute(decodedValue) + } + + suspend fun writeNullableCharStringAttribute(value: String, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16414u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute { + val ATTRIBUTE_ID: UInt = 16420u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableenumattr attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableEnumAttrAttribute(decodedValue) + } + + suspend fun writeNullableEnumAttrAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16420u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableStructAttribute(): NullableStructAttribute { + val ATTRIBUTE_ID: UInt = 16421u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablestruct attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UnitTestingClusterSimpleStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableStructAttribute(decodedValue) + } + + suspend fun writeNullableStructAttribute( + value: UnitTestingClusterSimpleStruct, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16421u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + value.toTlv(AnonymousTag, tlvWriter) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute { + val ATTRIBUTE_ID: UInt = 16422u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablerangerestrictedint8u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableRangeRestrictedInt8uAttribute(decodedValue) + } + + suspend fun writeNullableRangeRestrictedInt8uAttribute( + value: UByte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16422u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute { + val ATTRIBUTE_ID: UInt = 16423u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablerangerestrictedint8s attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableRangeRestrictedInt8sAttribute(decodedValue) + } + + suspend fun writeNullableRangeRestrictedInt8sAttribute( + value: Byte, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16423u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute { + val ATTRIBUTE_ID: UInt = 16424u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableRangeRestrictedInt16uAttribute(decodedValue) + } + + suspend fun writeNullableRangeRestrictedInt16uAttribute( + value: UShort, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16424u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute { + val ATTRIBUTE_ID: UInt = 16425u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableRangeRestrictedInt16sAttribute(decodedValue) + } + + suspend fun writeNullableRangeRestrictedInt16sAttribute( + value: Short, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 16425u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readWriteOnlyInt8uAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16426u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Writeonlyint8u attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeWriteOnlyInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 16426u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(UnitTestingCluster::class.java.name) + const val CLUSTER_ID: UInt = 4294048773u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt new file mode 100644 index 00000000000000..808ccdf68d8d94 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt @@ -0,0 +1,351 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) { + class LabelListAttribute(val value: List) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readLabelListAttribute(): LabelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Labellist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + + return LabelListAttribute(decodedValue) + } + + suspend fun writeLabelListAttribute( + value: List, + timedWriteTimeoutMs: Int? = null + ) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startArray(AnonymousTag) + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(UserLabelCluster::class.java.name) + const val CLUSTER_ID: UInt = 65u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt new file mode 100644 index 00000000000000..f0062adfb0851e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt @@ -0,0 +1,868 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ValveConfigurationAndControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OpenDurationAttribute(val value: UInt?) + + class AutoCloseTimeAttribute(val value: ULong?) + + class RemainingDurationAttribute(val value: UInt?) + + class CurrentStateAttribute(val value: UByte?) + + class TargetStateAttribute(val value: UByte?) + + class CurrentLevelAttribute(val value: UByte?) + + class TargetLevelAttribute(val value: UByte?) + + class OpenLevelAttribute(val value: UByte?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun open(openDuration: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_OPEN_DURATION_REQ: Int = 0 + openDuration?.let { tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun close(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun setLevel(level: UByte, openDuration: UInt?, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LEVEL_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LEVEL_REQ), level) + + val TAG_OPEN_DURATION_REQ: Int = 1 + openDuration?.let { tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) } + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readOpenDurationAttribute(): OpenDurationAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Openduration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OpenDurationAttribute(decodedValue) + } + + suspend fun writeOpenDurationAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 0u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Autoclosetime attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return AutoCloseTimeAttribute(decodedValue) + } + + suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Remainingduration attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return RemainingDurationAttribute(decodedValue) + } + + suspend fun readCurrentStateAttribute(): CurrentStateAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentStateAttribute(decodedValue) + } + + suspend fun readTargetStateAttribute(): TargetStateAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Targetstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return TargetStateAttribute(decodedValue) + } + + suspend fun readStartUpStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Startupstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun writeStartUpStateAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 5u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentLevelAttribute(decodedValue) + } + + suspend fun readTargetLevelAttribute(): TargetLevelAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Targetlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return TargetLevelAttribute(decodedValue) + } + + suspend fun readOpenLevelAttribute(): OpenLevelAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Openlevel attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OpenLevelAttribute(decodedValue) + } + + suspend fun writeOpenLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 8u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readValveFaultAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Valvefault attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(ValveConfigurationAndControlCluster::class.java.name) + const val CLUSTER_ID: UInt = 129u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt new file mode 100644 index 00000000000000..982b3d6118f1a7 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt @@ -0,0 +1,329 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader + +class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun readMACAddressAttribute(): String? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Macaddress attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readLinkLocalAddressAttribute(): ByteArray? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Linklocaladdress attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(WakeOnLanCluster::class.java.name) + const val CLUSTER_ID: UInt = 1283u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt new file mode 100644 index 00000000000000..79619f4ede4c05 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt @@ -0,0 +1,824 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class WiFiNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class BssidAttribute(val value: ByteArray?) + + class SecurityTypeAttribute(val value: UByte?) + + class WiFiVersionAttribute(val value: UByte?) + + class ChannelNumberAttribute(val value: UShort?) + + class RssiAttribute(val value: Byte?) + + class BeaconLostCountAttribute(val value: UInt?) + + class BeaconRxCountAttribute(val value: UInt?) + + class PacketMulticastRxCountAttribute(val value: UInt?) + + class PacketMulticastTxCountAttribute(val value: UInt?) + + class PacketUnicastRxCountAttribute(val value: UInt?) + + class PacketUnicastTxCountAttribute(val value: UInt?) + + class CurrentMaxRateAttribute(val value: ULong?) + + class OverrunCountAttribute(val value: ULong?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun resetCounts(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readBssidAttribute(): BssidAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Bssid attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BssidAttribute(decodedValue) + } + + suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Securitytype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return SecurityTypeAttribute(decodedValue) + } + + suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Wifiversion attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return WiFiVersionAttribute(decodedValue) + } + + suspend fun readChannelNumberAttribute(): ChannelNumberAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Channelnumber attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ChannelNumberAttribute(decodedValue) + } + + suspend fun readRssiAttribute(): RssiAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Rssi attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return RssiAttribute(decodedValue) + } + + suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Beaconlostcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BeaconLostCountAttribute(decodedValue) + } + + suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Beaconrxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return BeaconRxCountAttribute(decodedValue) + } + + suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Packetmulticastrxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PacketMulticastRxCountAttribute(decodedValue) + } + + suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Packetmulticasttxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PacketMulticastTxCountAttribute(decodedValue) + } + + suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Packetunicastrxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PacketUnicastRxCountAttribute(decodedValue) + } + + suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Packetunicasttxcount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return PacketUnicastTxCountAttribute(decodedValue) + } + + suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentmaxrate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentMaxRateAttribute(decodedValue) + } + + suspend fun readOverrunCountAttribute(): OverrunCountAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return OverrunCountAttribute(decodedValue) + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(WiFiNetworkDiagnosticsCluster::class.java.name) + const val CLUSTER_ID: UInt = 54u + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt new file mode 100644 index 00000000000000..f521fa0e72e514 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt @@ -0,0 +1,1308 @@ +/* + * + * 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. + */ + +package matter.controller.cluster.clusters + +import java.time.Duration +import java.util.logging.Level +import java.util.logging.Logger +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.MatterController +import matter.controller.ReadData +import matter.controller.ReadRequest +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class WindowCoveringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CurrentPositionLiftAttribute(val value: UShort?) + + class CurrentPositionTiltAttribute(val value: UShort?) + + class CurrentPositionLiftPercentageAttribute(val value: UByte?) + + class CurrentPositionTiltPercentageAttribute(val value: UByte?) + + class TargetPositionLiftPercent100thsAttribute(val value: UShort?) + + class TargetPositionTiltPercent100thsAttribute(val value: UShort?) + + class CurrentPositionLiftPercent100thsAttribute(val value: UShort?) + + class CurrentPositionTiltPercent100thsAttribute(val value: UShort?) + + class GeneratedCommandListAttribute(val value: List) + + class AcceptedCommandListAttribute(val value: List) + + class EventListAttribute(val value: List) + + class AttributeListAttribute(val value: List) + + suspend fun upOrOpen(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 0u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun downOrClose(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 1u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun stopMotion(timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 2u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun goToLiftValue(liftValue: UShort, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 4u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LIFT_VALUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun goToLiftPercentage( + liftPercent100thsValue: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 5u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_LIFT_PERCENT100THS_VALUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun goToTiltValue(tiltValue: UShort, timedInvokeTimeoutMs: Int? = null) { + val commandId: UInt = 7u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TILT_VALUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun goToTiltPercentage( + tiltPercent100thsValue: UShort, + timedInvokeTimeoutMs: Int? = null + ) { + val commandId: UInt = 8u + val timeoutMs: Duration = + timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_TILT_PERCENT100THS_VALUE_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timeoutMs + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun readTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Type attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Physicalclosedlimitlift attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Physicalclosedlimittilt attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentpositionlift attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPositionLiftAttribute(decodedValue) + } + + suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Currentpositiontilt attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPositionTiltAttribute(decodedValue) + } + + suspend fun readNumberOfActuationsLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofactuationslift attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readNumberOfActuationsTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Numberofactuationstilt attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readConfigStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Configstatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPositionLiftPercentageAttribute(decodedValue) + } + + suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPositionTiltPercentageAttribute(decodedValue) + } + + suspend fun readOperationalStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Operationalstatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readTargetPositionLiftPercent100thsAttribute(): + TargetPositionLiftPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return TargetPositionLiftPercent100thsAttribute(decodedValue) + } + + suspend fun readTargetPositionTiltPercent100thsAttribute(): + TargetPositionTiltPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return TargetPositionTiltPercent100thsAttribute(decodedValue) + } + + suspend fun readEndProductTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Endproducttype attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun readCurrentPositionLiftPercent100thsAttribute(): + CurrentPositionLiftPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPositionLiftPercent100thsAttribute(decodedValue) + } + + suspend fun readCurrentPositionTiltPercent100thsAttribute(): + CurrentPositionTiltPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in response" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return CurrentPositionTiltPercent100thsAttribute(decodedValue) + } + + suspend fun readInstalledOpenLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Installedopenlimitlift attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstalledClosedLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Installedclosedlimitlift attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstalledOpenLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Installedopenlimittilt attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readInstalledClosedLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Installedclosedlimittilt attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Mode attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + + return decodedValue + } + + suspend fun writeModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { + val ATTRIBUTE_ID: UInt = 23u + val timeoutMs: Duration = + timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), + timedRequest = timeoutMs + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun readSafetyStatusAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Safetystatus attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return GeneratedCommandListAttribute(decodedValue) + } + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AcceptedCommandListAttribute(decodedValue) + } + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return EventListAttribute(decodedValue) + } + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + + return AttributeListAttribute(decodedValue) + } + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + + return decodedValue + } + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + + return decodedValue + } + + companion object { + private val logger = Logger.getLogger(WindowCoveringCluster::class.java.name) + const val CLUSTER_ID: UInt = 258u + } +} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt similarity index 87% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index 50ec0a54a8ec73..bd0e6187f24cb5 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,9 +25,8 @@ import matter.tlv.TlvWriter class AccessControlClusterAccessControlEntryChangedEvent( val adminNodeID: ULong?, val adminPasscodeID: UShort?, - val changeType: UInt, - val latestValue: - matter.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, + val changeType: UByte, + val latestValue: matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, val fabricIndex: UByte ) { override fun toString(): String = buildString { @@ -90,11 +89,13 @@ class AccessControlClusterAccessControlEntryChangedEvent( tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) null } - val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) + val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) val latestValue = if (!tlvReader.isNull()) { - matter.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct - .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv( + ContextSpecificTag(TAG_LATEST_VALUE), + tlvReader + ) } else { tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) null diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index c6721f29f88959..aa38ea414d325f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,9 +25,9 @@ import matter.tlv.TlvWriter class AccessControlClusterAccessControlExtensionChangedEvent( val adminNodeID: ULong?, val adminPasscodeID: UShort?, - val changeType: UInt, + val changeType: UByte, val latestValue: - matter.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, val fabricIndex: UByte ) { override fun toString(): String = buildString { @@ -90,10 +90,10 @@ class AccessControlClusterAccessControlExtensionChangedEvent( tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) null } - val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) + val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) val latestValue = if (!tlvReader.isNull()) { - matter.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) } else { tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index 332ef0ac2dc29b..81e55baf4fe4f7 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index 7def1a047e9a3a..c1c26f5dc71c4a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,8 +25,8 @@ import matter.tlv.TlvWriter class ActionsClusterActionFailedEvent( val actionID: UShort, val invokeID: UInt, - val newState: UInt, - val error: UInt + val newState: UByte, + val error: UByte ) { override fun toString(): String = buildString { append("ActionsClusterActionFailedEvent {\n") @@ -58,8 +58,8 @@ class ActionsClusterActionFailedEvent( tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) - val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) - val error = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR)) + val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) + val error = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index 81ed599b956c26..25fdc842bf0af1 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,7 +25,7 @@ import matter.tlv.TlvWriter class ActionsClusterStateChangedEvent( val actionID: UShort, val invokeID: UInt, - val newState: UInt + val newState: UByte ) { override fun toString(): String = buildString { append("ActionsClusterStateChangedEvent {\n") @@ -54,7 +54,7 @@ class ActionsClusterStateChangedEvent( tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) - val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) + val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index 527ca9e747d32d..ea0e7e1e1004c4 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index 117e3e4472bedf..a6924b859aa024 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index cbcb04d823ae49..fff1d76a1fa86e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt index bf64761f255688..3918c2c126485e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class BooleanSensorConfigurationClusterAlarmsStateChangedEvent( - val alarmsActive: UInt, - val alarmsSuppressed: Optional + val alarmsActive: UByte, + val alarmsSuppressed: Optional ) { override fun toString(): String = buildString { append("BooleanSensorConfigurationClusterAlarmsStateChangedEvent {\n") @@ -55,10 +55,10 @@ class BooleanSensorConfigurationClusterAlarmsStateChangedEvent( tlvReader: TlvReader ): BooleanSensorConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) - val alarmsActive = tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_ACTIVE)) + val alarmsActive = tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_ACTIVE)) val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) } else { Optional.empty() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index b3ac5fad687aac..82db9ecdb2a8f4 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index f153ed3f64cc07..2bdca2fbfb016e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index 2df7a457951adf..e812711dad48f2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt similarity index 87% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index 92b680ff01eb05..21b147d7ffb931 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -26,28 +26,28 @@ import matter.tlv.TlvWriter class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( val eventID: ByteArray, val transitionIndex: UByte?, - val status: UInt, - val criticality: UInt, - val control: UInt, + val status: UByte, + val criticality: UByte, + val control: UShort, val temperatureControl: Optional< - matter.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct + matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct >?, val averageLoadControl: Optional< - matter.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct + matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct >?, val dutyCycleControl: Optional< - matter.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct + matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct >?, val powerSavingsControl: Optional< - matter.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct + matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct >?, val heatingSourceControl: Optional< - matter.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct + matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct >? ) { override fun toString(): String = buildString { @@ -146,14 +146,14 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) null } - val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) - val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) - val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) + val status = tlvReader.getUByte(ContextSpecificTag(TAG_STATUS)) + val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) + val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) val temperatureControl = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { Optional.of( - matter.devicecontroller.cluster.structs + matter.controller.cluster.structs .DemandResponseLoadControlClusterTemperatureControlStruct .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) ) @@ -168,7 +168,7 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { Optional.of( - matter.devicecontroller.cluster.structs + matter.controller.cluster.structs .DemandResponseLoadControlClusterAverageLoadControlStruct .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) ) @@ -183,7 +183,7 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { Optional.of( - matter.devicecontroller.cluster.structs + matter.controller.cluster.structs .DemandResponseLoadControlClusterDutyCycleControlStruct .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) ) @@ -198,7 +198,7 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { Optional.of( - matter.devicecontroller.cluster.structs + matter.controller.cluster.structs .DemandResponseLoadControlClusterPowerSavingsControlStruct .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) ) @@ -213,7 +213,7 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { Optional.of( - matter.devicecontroller.cluster.structs + matter.controller.cluster.structs .DemandResponseLoadControlClusterHeatingSourceControlStruct .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) ) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index dd7ac4d986fd58..10bda0f46af030 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class DeviceEnergyManagementClusterPowerAdjustEndEvent( - val cause: UInt, + val cause: UByte, val duration: UInt, val energyUse: Long ) { @@ -55,7 +55,7 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent( tlvReader: TlvReader ): DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) - val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) + val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt similarity index 80% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index 3b0bd74a1fd5c7..d6a5d9227ec845 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -14,19 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class DishwasherAlarmClusterNotifyEvent( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong + val active: UInt, + val inactive: UInt, + val state: UInt, + val mask: UInt ) { override fun toString(): String = buildString { append("DishwasherAlarmClusterNotifyEvent {\n") @@ -56,10 +56,10 @@ class DishwasherAlarmClusterNotifyEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) - val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) - val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) - val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) - val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) + val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) + val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) + val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) + val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt similarity index 85% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index 5acde4acb5f40d..233130a2371a2e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UInt) { +class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UByte) { override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") @@ -42,7 +42,7 @@ class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) - val alarmCode = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_CODE)) + val alarmCode = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_CODE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt similarity index 85% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index cc693ce9d5d390..92d04f6662dffe 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorStateChangeEvent(val doorState: UInt) { +class DoorLockClusterDoorStateChangeEvent(val doorState: UByte) { override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") @@ -42,7 +42,7 @@ class DoorLockClusterDoorStateChangeEvent(val doorState: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) - val doorState = tlvReader.getUInt(ContextSpecificTag(TAG_DOOR_STATE)) + val doorState = tlvReader.getUByte(ContextSpecificTag(TAG_DOOR_STATE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index 84b682fc2d55bb..0834fde8914a0d 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -25,14 +25,14 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class DoorLockClusterLockOperationErrorEvent( - val lockOperationType: UInt, - val operationSource: UInt, - val operationError: UInt, + val lockOperationType: UByte, + val operationSource: UByte, + val operationError: UByte, val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, val credentials: - Optional>? + Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") @@ -94,9 +94,9 @@ class DoorLockClusterLockOperationErrorEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) - val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) - val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val operationError = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_ERROR)) + val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) + val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) + val operationError = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_ERROR)) val userIndex = if (!tlvReader.isNull()) { tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) @@ -122,11 +122,11 @@ class DoorLockClusterLockOperationErrorEvent( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { Optional.of( - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) while (!tlvReader.isEndOfContainer()) { this.add( - matter.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( AnonymousTag, tlvReader ) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt similarity index 87% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index 4708017ff6fcae..c063f08d6d1e64 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -25,13 +25,13 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class DoorLockClusterLockOperationEvent( - val lockOperationType: UInt, - val operationSource: UInt, + val lockOperationType: UByte, + val operationSource: UByte, val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, val credentials: - Optional>? + Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") @@ -90,8 +90,8 @@ class DoorLockClusterLockOperationEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) - val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) - val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) + val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) + val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) val userIndex = if (!tlvReader.isNull()) { tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) @@ -117,11 +117,11 @@ class DoorLockClusterLockOperationEvent( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { Optional.of( - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) while (!tlvReader.isEndOfContainer()) { this.add( - matter.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( AnonymousTag, tlvReader ) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index 81814e6393b670..3d3cd635977b85 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class DoorLockClusterLockUserChangeEvent( - val lockDataType: UInt, - val dataOperationType: UInt, - val operationSource: UInt, + val lockDataType: UByte, + val dataOperationType: UByte, + val operationSource: UByte, val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, @@ -84,9 +84,9 @@ class DoorLockClusterLockUserChangeEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) - val lockDataType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) - val dataOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) - val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) + val lockDataType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) + val dataOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) + val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) val userIndex = if (!tlvReader.isNull()) { tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt new file mode 100644 index 00000000000000..2533881132950b --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -0,0 +1,96 @@ +/* + * + * 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. + */ +package matter.controller.cluster.eventstructs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + val energyImported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") + append("\tenergyImported : $energyImported\n") + append("\tenergyExported : $energyExported\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (energyImported.isPresent) { + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } + if (energyExported.isPresent) { + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } + endStructure() + } + } + + companion object { + private const val TAG_ENERGY_IMPORTED = 0 + private const val TAG_ENERGY_EXPORTED = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + tlvReader.enterStructure(tlvTag) + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt new file mode 100644 index 00000000000000..17194fbe3f7d84 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -0,0 +1,96 @@ +/* + * + * 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. + */ +package matter.controller.cluster.eventstructs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + val energyImported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") + append("\tenergyImported : $energyImported\n") + append("\tenergyExported : $energyExported\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (energyImported.isPresent) { + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } + if (energyExported.isPresent) { + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } + endStructure() + } + } + + companion object { + private const val TAG_ENERGY_IMPORTED = 0 + private const val TAG_ENERGY_EXPORTED = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + tlvReader.enterStructure(tlvTag) + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index d3357439368b80..a0770e7e82af07 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index 8f38fc18fdbacf..673441a49f6265 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,7 +25,7 @@ import matter.tlv.TlvWriter class EnergyEvseClusterEVNotDetectedEvent( val sessionID: UInt, - val state: UInt, + val state: UByte, val sessionDuration: UInt, val sessionEnergyCharged: Long, val sessionEnergyDischarged: Optional @@ -65,7 +65,7 @@ class EnergyEvseClusterEVNotDetectedEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) + val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) val sessionEnergyDischarged = diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 14630d9043c38d..0cd20e3e47ade3 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,7 +24,7 @@ import matter.tlv.TlvWriter class EnergyEvseClusterEnergyTransferStartedEvent( val sessionID: UInt, - val state: UInt, + val state: UByte, val maximumCurrent: Long ) { override fun toString(): String = buildString { @@ -53,7 +53,7 @@ class EnergyEvseClusterEnergyTransferStartedEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) + val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt similarity index 89% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index 8ce39cc2ccef2c..093f687fb16662 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,8 +24,8 @@ import matter.tlv.TlvWriter class EnergyEvseClusterEnergyTransferStoppedEvent( val sessionID: UInt, - val state: UInt, - val reason: UInt, + val state: UByte, + val reason: UByte, val energyTransferred: Long ) { override fun toString(): String = buildString { @@ -57,8 +57,8 @@ class EnergyEvseClusterEnergyTransferStoppedEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) + val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) + val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt similarity index 84% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index 71cdcae9dc193f..03e5ca83816f70 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,9 +24,9 @@ import matter.tlv.TlvWriter class EnergyEvseClusterFaultEvent( val sessionID: UInt, - val state: UInt, - val faultStatePreviousState: UInt, - val faultStateCurrentState: UInt + val state: UByte, + val faultStatePreviousState: UByte, + val faultStateCurrentState: UByte ) { override fun toString(): String = buildString { append("EnergyEvseClusterFaultEvent {\n") @@ -57,11 +57,11 @@ class EnergyEvseClusterFaultEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) + val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val faultStatePreviousState = - tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) val faultStateCurrentState = - tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index 65558cac9a6b7a..cf0fe503e13bd8 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt similarity index 89% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index 39205bf4badbef..8d13675dece145 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UInt) { +class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UByte) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") @@ -42,7 +42,7 @@ class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) - val bootReason = tlvReader.getUInt(ContextSpecificTag(TAG_BOOT_REASON)) + val bootReason = tlvReader.getUByte(ContextSpecificTag(TAG_BOOT_REASON)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index b24c90d6904e36..5b7e6cd0f947aa 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class GeneralDiagnosticsClusterHardwareFaultChangeEvent( - val current: List, - val previous: List + val current: List, + val previous: List ) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterHardwareFaultChangeEvent {\n") @@ -61,18 +61,18 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent( ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index f4423fa23b3783..f256dddde339d2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class GeneralDiagnosticsClusterNetworkFaultChangeEvent( - val current: List, - val previous: List + val current: List, + val previous: List ) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkFaultChangeEvent {\n") @@ -61,18 +61,18 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent( ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt similarity index 87% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index f42f34f9689d63..027949831806c8 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class GeneralDiagnosticsClusterRadioFaultChangeEvent( - val current: List, - val previous: List + val current: List, + val previous: List ) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterRadioFaultChangeEvent {\n") @@ -58,18 +58,18 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index f024905661f04f..3326660b5e35d0 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -14,21 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class MediaPlaybackClusterStateChangedEvent( - val currentState: UInt, + val currentState: UByte, val startTime: ULong, val duration: ULong, - val sampledPosition: - matter.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, + val sampledPosition: matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, val playbackSpeed: Float, val seekRangeEnd: ULong, val seekRangeStart: ULong, @@ -81,11 +80,11 @@ class MediaPlaybackClusterStateChangedEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) - val currentState = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_STATE)) + val currentState = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) val sampledPosition = - matter.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( + matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader ) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index f2f65bc0d0e509..4ae90661a7b56b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OperationalStateClusterOperationCompletionEvent( - val completionErrorCode: UInt, + val completionErrorCode: UByte, val totalOperationalTime: Optional?, val pausedTime: Optional? ) { @@ -70,7 +70,7 @@ class OperationalStateClusterOperationCompletionEvent( tlvReader: TlvReader ): OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) - val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) + val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) val totalOperationalTime = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt similarity index 84% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index 802e306c594c80..fc6e4797a28b46 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OperationalStateClusterOperationalErrorEvent( - val errorState: matter.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct + val errorState: matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct ) { override fun toString(): String = buildString { append("OperationalStateClusterOperationalErrorEvent {\n") @@ -45,7 +45,7 @@ class OperationalStateClusterOperationalErrorEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) val errorState = - matter.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( + matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( ContextSpecificTag(TAG_ERROR_STATE), tlvReader ) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index a36f9161a81b62..e3fbe9c5bf247f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index 993efa8e9c93fc..52ff425323115b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( - val previousState: UInt, - val newState: UInt, - val reason: UInt, + val previousState: UByte, + val newState: UByte, + val reason: UByte, val targetSoftwareVersion: UInt? ) { override fun toString(): String = buildString { @@ -63,9 +63,9 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( tlvReader: TlvReader ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) - val previousState = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_STATE)) - val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) - val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) + val previousState = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_STATE)) + val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) + val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) val targetSoftwareVersion = if (!tlvReader.isNull()) { tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index f8b32d0d560892..cd39219a42e3bf 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index ea444f0c055c3f..7220e0afa693d2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterOperationCompletionEvent( - val completionErrorCode: UInt, + val completionErrorCode: UByte, val totalOperationalTime: Optional?, val pausedTime: Optional? ) { @@ -70,7 +70,7 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( tlvReader: TlvReader ): OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) - val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) + val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) val totalOperationalTime = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt similarity index 81% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index fbc411ab8f4d19..bfaa8f75b3b597 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,7 +24,7 @@ import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterOperationalErrorEvent( val errorState: - matter.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct + matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct ) { override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") @@ -49,8 +49,10 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent( ): OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) val errorState = - matter.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct - .fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt similarity index 87% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index 21cdcf674fa338..8e189c26173639 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class PowerSourceClusterBatChargeFaultChangeEvent( - val current: List, - val previous: List + val current: List, + val previous: List ) { override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeEvent {\n") @@ -58,18 +58,18 @@ class PowerSourceClusterBatChargeFaultChangeEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt similarity index 85% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index d1fd41e582dc94..7aa1a81b862fd5 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { +class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -55,18 +55,18 @@ class PowerSourceClusterBatFaultChangeEvent(val current: List, val previou fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 8aaacc0cb49fc4..5dc6444f06cd51 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { +class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -55,18 +55,18 @@ class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt similarity index 80% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index ee7c9b8ebfaae6..8bfdf23df2be69 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -14,19 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class RefrigeratorAlarmClusterNotifyEvent( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong + val active: UInt, + val inactive: UInt, + val state: UInt, + val mask: UInt ) { override fun toString(): String = buildString { append("RefrigeratorAlarmClusterNotifyEvent {\n") @@ -56,10 +56,10 @@ class RefrigeratorAlarmClusterNotifyEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) - val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) - val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) - val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) - val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) + val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) + val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) + val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) + val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index 3004686f8b67d8..eaafde5a0c8c68 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcOperationalStateClusterOperationCompletionEvent( - val completionErrorCode: UInt, + val completionErrorCode: UByte, val totalOperationalTime: Optional?, val pausedTime: Optional? ) { @@ -70,7 +70,7 @@ class RvcOperationalStateClusterOperationCompletionEvent( tlvReader: TlvReader ): RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) - val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) + val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) val totalOperationalTime = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt similarity index 84% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index ff973d17fe9684..7a78710f647235 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcOperationalStateClusterOperationalErrorEvent( - val errorState: matter.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct + val errorState: matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct ) { override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalErrorEvent {\n") @@ -48,7 +48,7 @@ class RvcOperationalStateClusterOperationalErrorEvent( ): RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) val errorState = - matter.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( + matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( ContextSpecificTag(TAG_ERROR_STATE), tlvReader ) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt new file mode 100644 index 00000000000000..5570ba7a3af4a3 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -0,0 +1,56 @@ +/* + * + * 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. + */ +package matter.controller.cluster.eventstructs + +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SampleMeiClusterPingCountEventEvent(val count: UInt, val fabricIndex: UByte) { + override fun toString(): String = buildString { + append("SampleMeiClusterPingCountEventEvent {\n") + append("\tcount : $count\n") + append("\tfabricIndex : $fabricIndex\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_COUNT), count) + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + endStructure() + } + } + + companion object { + private const val TAG_COUNT = 1 + private const val TAG_FABRIC_INDEX = 254 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { + tlvReader.enterStructure(tlvTag) + val count = tlvReader.getUInt(ContextSpecificTag(TAG_COUNT)) + val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + + tlvReader.exitContainer() + + return SampleMeiClusterPingCountEventEvent(count, fabricIndex) + } + } +} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt similarity index 84% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index e70b19a92636d3..52c7a19053aacb 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UInt) { +class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -42,7 +42,7 @@ class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) - val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) + val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index 51aa58966bfd4c..80c6a860b1ccc0 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UInt) { +class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -42,7 +42,7 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UInt) fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) - val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) + val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 4f2f7187caaa90..2a3f3f2d05c730 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UInt) { +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -42,7 +42,7 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UIn fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) - val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) + val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index 0fd098880eddcf..3930c40935d0ef 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UInt) { +class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -42,7 +42,7 @@ class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) - val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) + val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index f2b985b06eb48f..934c42da5479a2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UInt) { +class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -42,7 +42,7 @@ class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) - val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) + val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index f7e1378e5ed2b7..c7ac6b65eae4dc 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index 630fd921464fad..f7a74f79826494 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index b586d1687d64a9..bacc49c76bbc53 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index 6b7ea992a3821e..cbd0166269542b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index 79bbef0ee9dd7d..4a82b4914ea426 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index bced01633d76ef..4bf6776e64f14a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index 6c9c2272f2ab38..c08c0e63f8b5e1 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index 8c5ee4f9f83edf..4aae22fb446979 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt similarity index 84% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index bfe84759bfb77b..0d56be60d4b36e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,7 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class TargetNavigatorClusterTargetUpdatedEvent( - val targetList: - List, + val targetList: List, val currentTarget: UByte, val data: ByteArray ) { @@ -59,12 +58,14 @@ class TargetNavigatorClusterTargetUpdatedEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) val targetList = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) while (!tlvReader.isEndOfContainer()) { this.add( - matter.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct - .fromTlv(AnonymousTag, tlvReader) + matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( + AnonymousTag, + tlvReader + ) ) } tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index b771bd2b0f402c..8acbb4b6aea971 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -45,7 +45,7 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: tlvReader: TlvReader ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) - val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) + val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index 827abfa1377c6a..3bea74d8323077 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( - val current: List, - val previous: List + val current: List, + val previous: List ) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent {\n") @@ -61,18 +61,18 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index e20bc34335426f..1f92e4003e280a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 552027845f991d..0ef92440535c0a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt similarity index 81% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index 2993e43dedc6cd..b95fb1a6114b7f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -25,11 +25,11 @@ import matter.tlv.TlvWriter class UnitTestingClusterTestEventEvent( val arg1: UByte, - val arg2: UInt, + val arg2: UByte, val arg3: Boolean, - val arg4: matter.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, - val arg5: List, - val arg6: List + val arg4: matter.controller.cluster.structs.UnitTestingClusterSimpleStruct, + val arg5: List, + val arg6: List ) { override fun toString(): String = buildString { append("UnitTestingClusterTestEventEvent {\n") @@ -74,19 +74,19 @@ class UnitTestingClusterTestEventEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) - val arg2 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG2)) + val arg2 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) val arg4 = - matter.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( ContextSpecificTag(TAG_ARG4), tlvReader ) val arg5 = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) while (!tlvReader.isEndOfContainer()) { this.add( - matter.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( AnonymousTag, tlvReader ) @@ -95,10 +95,10 @@ class UnitTestingClusterTestEventEvent( tlvReader.exitContainer() } val arg6 = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) + this.add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index bdf1b54a00b31f..b0ac8683c99209 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt similarity index 89% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index 6aa0f2c8ea44bf..6c207e60058efa 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UInt) { +class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UShort) { override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") @@ -45,7 +45,7 @@ class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UInt) { tlvReader: TlvReader ): ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) - val valveFault = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_FAULT)) + val valveFault = tlvReader.getUShort(ContextSpecificTag(TAG_VALVE_FAULT)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index 37e58c25cea495..4ff645d6acaf8c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveStateChangedEvent(val valveState: UInt) { +class ValveConfigurationAndControlClusterValveStateChangedEvent(val valveState: UByte) { override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveStateChangedEvent {\n") append("\tvalveState : $valveState\n") @@ -45,7 +45,7 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent(val valveState: tlvReader: TlvReader ): ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) - val valveState = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_STATE)) + val valveState = tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_STATE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index 04b408b87c41c2..677577429c1796 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( - val associationFailureCause: UInt, + val associationFailureCause: UByte, val status: UShort ) { override fun toString(): String = buildString { @@ -52,7 +52,7 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) val associationFailureCause = - tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUShort(ContextSpecificTag(TAG_STATUS)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index 653e02a013159d..af8d2c296abe2e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -45,7 +45,7 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: U tlvReader: TlvReader ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) - val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) + val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt rename to src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index 518f3ece0161d2..a61a9742ede95a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/controller/cluster/files.gni b/src/controller/java/generated/java/matter/controller/cluster/files.gni new file mode 100644 index 00000000000000..d7d18479992e91 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -0,0 +1,313 @@ +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +matter_structs_sources = [ + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterAttributeValuePair.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterExtensionFieldSet.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterSceneInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt", +] + +matter_eventstructs_sources = [ + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt", +] + +matter_clusters_sources = [ + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanSensorConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt", +] \ No newline at end of file diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt similarity index 92% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index 7160b776b170fb..f177b65134c50c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class AccessControlClusterAccessControlEntryStruct( - val privilege: UInt, - val authMode: UInt, + val privilege: UByte, + val authMode: UByte, val subjects: List?, val targets: List?, val fabricIndex: UByte @@ -77,8 +77,8 @@ class AccessControlClusterAccessControlEntryStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlEntryStruct { tlvReader.enterStructure(tlvTag) - val privilege = tlvReader.getUInt(ContextSpecificTag(TAG_PRIVILEGE)) - val authMode = tlvReader.getUInt(ContextSpecificTag(TAG_AUTH_MODE)) + val privilege = tlvReader.getUByte(ContextSpecificTag(TAG_PRIVILEGE)) + val authMode = tlvReader.getUByte(ContextSpecificTag(TAG_AUTH_MODE)) val subjects = if (!tlvReader.isNull()) { buildList { diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index 92f871d9cc054d..4427b4a4671abe 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index 24905a80d950d9..c0197f9d712c79 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt index 43a6ed963d8b52..73476687b0478e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,10 +25,10 @@ import matter.tlv.TlvWriter class ActionsClusterActionStruct( val actionID: UShort, val name: String, - val type: UInt, + val type: UByte, val endpointListID: UShort, - val supportedCommands: UInt, - val state: UInt + val supportedCommands: UShort, + val state: UByte ) { override fun toString(): String = buildString { append("ActionsClusterActionStruct {\n") @@ -66,10 +66,10 @@ class ActionsClusterActionStruct( tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) + val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) - val supportedCommands = tlvReader.getUInt(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) - val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) + val supportedCommands = tlvReader.getUShort(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) + val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt index 7b0f6a5616f52f..94dda8930854be 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -26,7 +26,7 @@ import matter.tlv.TlvWriter class ActionsClusterEndpointListStruct( val endpointListID: UShort, val name: String, - val type: UInt, + val type: UByte, val endpoints: List ) { override fun toString(): String = buildString { @@ -63,7 +63,7 @@ class ActionsClusterEndpointListStruct( tlvReader.enterStructure(tlvTag) val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) + val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) val endpoints = buildList { tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index 3f3b66764532b4..afa7a17f5647c8 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( - val productIdentifierType: UInt, + val productIdentifierType: UByte, val productIdentifierValue: String ) { override fun toString(): String = buildString { @@ -51,7 +51,8 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( tlvReader: TlvReader ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierType = + tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index 90dae8f1054f47..2172fbb67b699f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index 62fc820b748084..9329e2a02a429b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index 39fa26c5279bbc..823ca308e47dde 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 07c6c02e0e16af..03f59264fc2501 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -14,15 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AudioOutputClusterOutputInfoStruct(val index: UByte, val outputType: UInt, val name: String) { +class AudioOutputClusterOutputInfoStruct( + val index: UByte, + val outputType: UByte, + val name: String +) { override fun toString(): String = buildString { append("AudioOutputClusterOutputInfoStruct {\n") append("\tindex : $index\n") @@ -49,7 +53,7 @@ class AudioOutputClusterOutputInfoStruct(val index: UByte, val outputType: UInt, fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AudioOutputClusterOutputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUByte(ContextSpecificTag(TAG_INDEX)) - val outputType = tlvReader.getUInt(ContextSpecificTag(TAG_OUTPUT_TYPE)) + val outputType = tlvReader.getUByte(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index 57ffe931e64877..a25807e0c8d155 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index b1bd7ea2c5599b..56583564b0c687 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val primaryColor: UInt?) { +class BasicInformationClusterProductAppearanceStruct(val finish: UByte, val primaryColor: UByte?) { override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") @@ -49,10 +49,10 @@ class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val prima fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) - val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) + val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) } else { tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) null diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt index 2f41f19897474b..84be9b6dd69995 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index c6b0dea505512d..94e9b134c06b09 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class BridgedDeviceBasicInformationClusterProductAppearanceStruct( - val finish: UInt, - val primaryColor: UInt? + val finish: UByte, + val primaryColor: UByte? ) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterProductAppearanceStruct {\n") @@ -55,10 +55,10 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct( tlvReader: TlvReader ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) - val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) + val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) } else { tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) null diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index 0b79ff3eb596ad..cd2eacc749cb0d 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt index 140a9efa1979ba..627dcdcbefa16f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -30,7 +30,7 @@ class ChannelClusterChannelInfoStruct( val callSign: Optional, val affiliateCallSign: Optional, val identifier: Optional, - val type: Optional + val type: Optional ) { override fun toString(): String = buildString { append("ChannelClusterChannelInfoStruct {\n") @@ -112,7 +112,7 @@ class ChannelClusterChannelInfoStruct( } val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) } else { Optional.empty() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt index 8be6df885ae3e7..3d190489316d4a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt index cb1ab50c1e95db..e8e25f3fe16a7e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -27,7 +27,7 @@ class ChannelClusterLineupInfoStruct( val operatorName: String, val lineupName: Optional, val postalCode: Optional, - val lineupInfoType: UInt + val lineupInfoType: UByte ) { override fun toString(): String = buildString { append("ChannelClusterLineupInfoStruct {\n") @@ -76,7 +76,7 @@ class ChannelClusterLineupInfoStruct( } else { Optional.empty() } - val lineupInfoType = tlvReader.getUInt(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) + val lineupInfoType = tlvReader.getUByte(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt index 9a589addf25a34..e9712955df7799 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt index a5bc79e5602b86..45b0a22100ef25 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index 9f0756a7e762af..6e89f24cd39e25 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt index 434d64c9bc8ad4..f40e13d0894446 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -39,7 +39,7 @@ class ChannelClusterProgramStruct( val dvbiUrl: Optional, val releaseDate: Optional, val parentalGuidanceText: Optional, - val recordingFlag: Optional, + val recordingFlag: Optional, val seriesInfo: Optional?, val categoryList: Optional>, val castList: Optional>, @@ -262,7 +262,7 @@ class ChannelClusterProgramStruct( } val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) } else { Optional.empty() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index 0052c32a87ec6b..9e3928a48de8a5 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt index af2a6a33a9048e..c47570f255caaa 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index e58a8923415e3b..af51becfe86381 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index 7fc9456852969f..4470b659b2e59f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index edb9b9abc81976..1fe0fc71463ee6 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index 02b1322f5f9f17..f9c4eb2d6f4502 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,7 +25,7 @@ import matter.tlv.TlvWriter class ContentLauncherClusterDimensionStruct( val width: Double, val height: Double, - val metric: UInt + val metric: UByte ) { override fun toString(): String = buildString { append("ContentLauncherClusterDimensionStruct {\n") @@ -54,7 +54,7 @@ class ContentLauncherClusterDimensionStruct( tlvReader.enterStructure(tlvTag) val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) - val metric = tlvReader.getUInt(ContextSpecificTag(TAG_METRIC)) + val metric = tlvReader.getUByte(ContextSpecificTag(TAG_METRIC)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt index ee1efa7365917b..e0975b8e1c6c9f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -25,7 +25,7 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class ContentLauncherClusterParameterStruct( - val type: UInt, + val type: UByte, val value: String, val externalIDList: Optional> ) { @@ -61,7 +61,7 @@ class ContentLauncherClusterParameterStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterParameterStruct { tlvReader.enterStructure(tlvTag) - val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) + val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index 66cd44f198e5f8..694f35fc4364d1 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index 217d11a7712d03..e57d04e099fb44 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt similarity index 92% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index 3dc13d4aed478e..74c3088d135bcc 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -26,7 +26,7 @@ import matter.tlv.TlvWriter class ContentLauncherClusterTrackPreferenceStruct( val languageCode: String, - val characteristics: Optional>, + val characteristics: Optional>, val audioOutputIndex: UByte ) { override fun toString(): String = buildString { @@ -65,10 +65,10 @@ class ContentLauncherClusterTrackPreferenceStruct( val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { Optional.of( - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index 1e4fd9f18cfe1d..4473bd4520dcd2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index 1e23b648c727a9..7e53d779dda4e3 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index 0be25f2696b61c..aeae2026e12db2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UInt) { +class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") @@ -45,7 +45,7 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSour tlvReader: TlvReader ): DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) - val heatingSource = tlvReader.getUInt(ContextSpecificTag(TAG_HEATING_SOURCE)) + val heatingSource = tlvReader.getUByte(ContextSpecificTag(TAG_HEATING_SOURCE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt similarity index 92% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index fff221a680f729..e8f15e8cdb0064 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -27,10 +27,10 @@ import matter.tlv.TlvWriter class DemandResponseLoadControlClusterLoadControlEventStruct( val eventID: ByteArray, val programID: ByteArray?, - val control: UInt, - val deviceClass: ULong, + val control: UShort, + val deviceClass: UInt, val enrollmentGroup: Optional, - val criticality: UInt, + val criticality: UByte, val startTime: UInt?, val transitions: List ) { @@ -100,15 +100,15 @@ class DemandResponseLoadControlClusterLoadControlEventStruct( tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) null } - val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val deviceClass = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_CLASS)) + val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) + val deviceClass = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_CLASS)) val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) } else { Optional.empty() } - val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) + val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) val startTime = if (!tlvReader.isNull()) { tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index 46c70edba6e5c8..1bad4e81db4b9a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,7 +25,7 @@ import matter.tlv.TlvWriter class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( val duration: UShort, - val control: UInt, + val control: UShort, val temperatureControl: Optional, val averageLoadControl: Optional, val dutyCycleControl: Optional, @@ -88,7 +88,7 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUShort(ContextSpecificTag(TAG_DURATION)) - val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) + val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { Optional.of( diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index fd21d4d07fb729..d3aea5654d479b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt similarity index 94% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index 363970d31ad65a..485257eb7dbf1c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index 89d78db74606f3..635b2541684b05 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index b7b19082af7379..c8cc82e04d50eb 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index 2dd5869528c27f..70a83556618698 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,8 +25,8 @@ import matter.tlv.TlvWriter class DescriptorClusterSemanticTagStruct( val mfgCode: UShort?, - val namespaceID: UInt, - val tag: UInt, + val namespaceID: UByte, + val tag: UByte, val label: Optional? ) { override fun toString(): String = buildString { @@ -75,8 +75,8 @@ class DescriptorClusterSemanticTagStruct( tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) null } - val namespaceID = tlvReader.getUInt(ContextSpecificTag(TAG_NAMESPACE_I_D)) - val tag = tlvReader.getUInt(ContextSpecificTag(TAG_TAG)) + val namespaceID = tlvReader.getUByte(ContextSpecificTag(TAG_NAMESPACE_I_D)) + val tag = tlvReader.getUByte(ContextSpecificTag(TAG_TAG)) val label = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index a6beed8757434f..4649721a71284b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index 58f037e4bfe968..c08ce3a1eaf582 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class DeviceEnergyManagementClusterCostStruct( - val costType: UInt, + val costType: UByte, val value: Int, val decimalPoints: UByte, val currency: Optional @@ -60,7 +60,7 @@ class DeviceEnergyManagementClusterCostStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterCostStruct { tlvReader.enterStructure(tlvTag) - val costType = tlvReader.getUInt(ContextSpecificTag(TAG_COST_TYPE)) + val costType = tlvReader.getUByte(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getInt(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUByte(ContextSpecificTag(TAG_DECIMAL_POINTS)) val currency = diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index 40b5fe9be7d839..6910c799cd8268 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index 717a274783bb5b..c1822bb573e344 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index b0b1a5f7787626..e11febdfd6a489 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt similarity index 99% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index d2a1ede063e1fb..d3121dc411a4de 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index d35df126ab13bd..3d61c5bccf50cf 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index 7e3d6bbe24ecdb..584dc79028182c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { +class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -55,7 +55,7 @@ class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val valu } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt index 4ee0122fa76b0c..f66b57f47660ca 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterCredentialStruct(val credentialType: UInt, val credentialIndex: UShort) { +class DoorLockClusterCredentialStruct(val credentialType: UByte, val credentialIndex: UShort) { override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") @@ -45,7 +45,7 @@ class DoorLockClusterCredentialStruct(val credentialType: UInt, val credentialIn fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterCredentialStruct { tlvReader.enterStructure(tlvTag) - val credentialType = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) + val credentialType = tlvReader.getUByte(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUShort(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt new file mode 100644 index 00000000000000..46dff94ff6a1cb --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -0,0 +1,116 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + val energy: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterEnergyMeasurementStruct {\n") + append("\tenergy : $energy\n") + append("\tstartTimestamp : $startTimestamp\n") + append("\tendTimestamp : $endTimestamp\n") + append("\tstartSystime : $startSystime\n") + append("\tendSystime : $endSystime\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_ENERGY), energy) + if (startTimestamp.isPresent) { + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } + if (endTimestamp.isPresent) { + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } + if (startSystime.isPresent) { + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } + if (endSystime.isPresent) { + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } + endStructure() + } + } + + companion object { + private const val TAG_ENERGY = 0 + private const val TAG_START_TIMESTAMP = 1 + private const val TAG_END_TIMESTAMP = 2 + private const val TAG_START_SYSTIME = 3 + private const val TAG_END_SYSTIME = 4 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + tlvReader.enterStructure(tlvTag) + val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt new file mode 100644 index 00000000000000..65ed89eee4272d --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -0,0 +1,150 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct {\n") + append("\trangeMin : $rangeMin\n") + append("\trangeMax : $rangeMax\n") + append("\tpercentMax : $percentMax\n") + append("\tpercentMin : $percentMin\n") + append("\tpercentTypical : $percentTypical\n") + append("\tfixedMax : $fixedMax\n") + append("\tfixedMin : $fixedMin\n") + append("\tfixedTypical : $fixedTypical\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) + put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) + if (percentMax.isPresent) { + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } + if (percentMin.isPresent) { + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } + if (percentTypical.isPresent) { + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } + if (fixedMax.isPresent) { + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } + if (fixedMin.isPresent) { + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } + if (fixedTypical.isPresent) { + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } + endStructure() + } + } + + companion object { + private const val TAG_RANGE_MIN = 0 + private const val TAG_RANGE_MAX = 1 + private const val TAG_PERCENT_MAX = 2 + private const val TAG_PERCENT_MIN = 3 + private const val TAG_PERCENT_TYPICAL = 4 + private const val TAG_FIXED_MAX = 5 + private const val TAG_FIXED_MIN = 6 + private const val TAG_FIXED_TYPICAL = 7 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + tlvReader.enterStructure(tlvTag) + val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) + val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt new file mode 100644 index 00000000000000..b8f7a0f8ff429e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -0,0 +1,100 @@ +/* + * + * 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. + */ +package matter.controller.cluster.structs + +import matter.controller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UShort, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { + append("ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct {\n") + append("\tmeasurementType : $measurementType\n") + append("\tmeasured : $measured\n") + append("\tminMeasuredValue : $minMeasuredValue\n") + append("\tmaxMeasuredValue : $maxMeasuredValue\n") + append("\taccuracyRanges : $accuracyRanges\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_MEASUREMENT_TYPE), measurementType) + put(ContextSpecificTag(TAG_MEASURED), measured) + put(ContextSpecificTag(TAG_MIN_MEASURED_VALUE), minMeasuredValue) + put(ContextSpecificTag(TAG_MAX_MEASURED_VALUE), maxMeasuredValue) + startArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + for (item in accuracyRanges.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + endStructure() + } + } + + companion object { + private const val TAG_MEASUREMENT_TYPE = 0 + private const val TAG_MEASURED = 1 + private const val TAG_MIN_MEASURED_VALUE = 2 + private const val TAG_MAX_MEASURED_VALUE = 3 + private const val TAG_ACCURACY_RANGES = 4 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + tlvReader.enterStructure(tlvTag) + val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) + val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) + val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) + val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + + tlvReader.exitContainer() + + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) + } + } +} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index a81f4c8716c8e8..65c1b49f4af9f1 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt index 07a231555999fa..b5181c44417b6d 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt index e8638055916ae0..aa7528a466dece 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt index 900e71adea7c6d..200b75dde048f4 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -31,7 +31,7 @@ class GeneralDiagnosticsClusterNetworkInterface( val hardwareAddress: ByteArray, val IPv4Addresses: List, val IPv6Addresses: List, - val type: UInt + val type: UByte ) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkInterface {\n") @@ -128,7 +128,7 @@ class GeneralDiagnosticsClusterNetworkInterface( } tlvReader.exitContainer() } - val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) + val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index cfa9eb7e88060c..9d0155111d4207 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index 96460161128bbe..e5f8ecb177a11b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index 2c8d334a4cffd9..d68d0536b9bd30 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,7 +24,7 @@ import matter.tlv.TlvWriter class GroupKeyManagementClusterGroupKeySetStruct( val groupKeySetID: UShort, - val groupKeySecurityPolicy: UInt, + val groupKeySecurityPolicy: UByte, val epochKey0: ByteArray?, val epochStartTime0: ULong?, val epochKey1: ByteArray?, @@ -98,7 +98,7 @@ class GroupKeyManagementClusterGroupKeySetStruct( tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val groupKeySecurityPolicy = - tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) val epochKey0 = if (!tlvReader.isNull()) { tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt similarity index 89% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index 32ce0e6298f485..99d8d0dfd05c83 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class HepaFilterMonitoringClusterReplacementProductStruct( - val productIdentifierType: UInt, + val productIdentifierType: UByte, val productIdentifierValue: String ) { override fun toString(): String = buildString { @@ -51,7 +51,8 @@ class HepaFilterMonitoringClusterReplacementProductStruct( tlvReader: TlvReader ): HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierType = + tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index 2a7a56c9a650dd..d3f81f766efb96 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index 08988b2b2dfa27..e8392fab770bf0 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index 0284a239b9b610..a12e2840ead4ab 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { +class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -55,7 +55,7 @@ class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val v } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt index ef3a028b680b8a..2aaef4b767542e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,7 +24,7 @@ import matter.tlv.TlvWriter class MediaInputClusterInputInfoStruct( val index: UByte, - val inputType: UInt, + val inputType: UByte, val name: String, val description: String ) { @@ -57,7 +57,7 @@ class MediaInputClusterInputInfoStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaInputClusterInputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUByte(ContextSpecificTag(TAG_INDEX)) - val inputType = tlvReader.getUInt(ContextSpecificTag(TAG_INPUT_TYPE)) + val inputType = tlvReader.getUByte(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index 3052f1984c2412..518da6b739efc8 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index 2f0004844a3996..dfd99da8565408 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index 347b99dd6b0245..0571df7456c16e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 481ae34118a03b..8af30d0c768cf7 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index d0d088a1d77b42..ee00730c425f47 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { +class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -55,7 +55,7 @@ class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val v } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index 8cb331e77ade86..558980bb83460a 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index 5b6d1ae0fb71f0..fe6cdd3b787f01 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UInt) { +class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UShort) { override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -46,7 +46,7 @@ class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UInt) { fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index 245061cc19fc46..ebb7d9c32e5609 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index 5057fa34bc1cbe..93df116f49e63e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt similarity index 90% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index 3d2c8ea65a32bd..ffbb05f45a6b51 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -14,20 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( - val security: UInt, + val security: UByte, val ssid: ByteArray, val bssid: ByteArray, val channel: UShort, - val wiFiBand: UInt, + val wiFiBand: UByte, val rssi: Byte ) { override fun toString(): String = buildString { @@ -67,11 +67,11 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( tlvReader: TlvReader ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) - val security = tlvReader.getUInt(ContextSpecificTag(TAG_SECURITY)) + val security = tlvReader.getUByte(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) val bssid = tlvReader.getByteArray(ContextSpecificTag(TAG_BSSID)) val channel = tlvReader.getUShort(ContextSpecificTag(TAG_CHANNEL)) - val wiFiBand = tlvReader.getUInt(ContextSpecificTag(TAG_WI_FI_BAND)) + val wiFiBand = tlvReader.getUByte(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index 66de75d6e3efc1..89b9428c741564 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index ab86611164d93d..3a104b0d78b127 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index f49646d015d186..f1d7a22e7e757b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OperationalStateClusterErrorStateStruct( - val errorStateID: UInt, + val errorStateID: UByte, val errorStateLabel: Optional, val errorStateDetails: Optional ) { @@ -59,7 +59,7 @@ class OperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) - val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) + val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index 238035d38a060e..d08dc7aa0df6e9 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OperationalStateClusterOperationalStateStruct( - val operationalStateID: UInt, + val operationalStateID: UByte, val operationalStateLabel: Optional ) { override fun toString(): String = buildString { @@ -52,7 +52,7 @@ class OperationalStateClusterOperationalStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) - val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) + val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index 1fe882a3da1674..f9dd92cc8640f3 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index 5b98278cda9aa4..3ca1059ea25628 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterErrorStateStruct( - val errorStateID: UInt, + val errorStateID: UByte, val errorStateLabel: Optional, val errorStateDetails: Optional ) { @@ -62,7 +62,7 @@ class OvenCavityOperationalStateClusterErrorStateStruct( tlvReader: TlvReader ): OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) - val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) + val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index 51b2811215e0cc..f66b7a09928db4 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterOperationalStateStruct( - val operationalStateID: UInt, + val operationalStateID: UByte, val operationalStateLabel: Optional ) { override fun toString(): String = buildString { @@ -55,7 +55,7 @@ class OvenCavityOperationalStateClusterOperationalStateStruct( tlvReader: TlvReader ): OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) - val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) + val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt index de09bc2413be77..ba8bad6b42ff54 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt index f957f7073fa77a..4ba9d368de022f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { +class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -55,7 +55,7 @@ class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UIn } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt similarity index 88% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index b052cd4bd801ed..8b9487ac66f3e3 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,8 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class PowerSourceClusterBatChargeFaultChangeType( - val current: List, - val previous: List + val current: List, + val previous: List ) { override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeType {\n") @@ -58,18 +58,18 @@ class PowerSourceClusterBatChargeFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt similarity index 86% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index e6ed2093eea21a..6b849cc5874313 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { +class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") @@ -55,18 +55,18 @@ class PowerSourceClusterBatFaultChangeType(val current: List, val previous fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt similarity index 89% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index e2849017a263c9..9354883b16e760 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { +class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") @@ -55,18 +55,18 @@ class PowerSourceClusterWiredFaultChangeType(val current: List, val previo fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) val current = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } val previous = - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index 41c4276b72942a..cd01932bc3f167 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt similarity index 92% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index 66ac75104984a2..9faf469741368c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,7 +25,7 @@ import matter.tlv.TlvWriter class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( val mfgCode: Optional, - val value: UInt + val value: UShort ) { override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct {\n") @@ -61,7 +61,7 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index b718ee935b7990..a8e74c89f3ad1d 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index b6670bdcd7b955..ce35ad9a5a9960 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { +class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -55,7 +55,7 @@ class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt similarity index 93% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 4907820103b662..6fa68a81b810ad 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcOperationalStateClusterErrorStateStruct( - val errorStateID: UInt, + val errorStateID: UByte, val errorStateLabel: Optional, val errorStateDetails: Optional ) { @@ -59,7 +59,7 @@ class RvcOperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) - val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) + val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index 1e5548ff7677a9..f21d5ecb4da1cf 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcOperationalStateClusterOperationalStateStruct( - val operationalStateID: UInt, + val operationalStateID: UByte, val operationalStateLabel: Optional ) { override fun toString(): String = buildString { @@ -55,7 +55,7 @@ class RvcOperationalStateClusterOperationalStateStruct( tlvReader: TlvReader ): RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) - val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) + val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index 937a0303a98b04..f4193b91fac485 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index 055336e7a1e250..7ad69693847d17 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { +class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -55,7 +55,7 @@ class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: U } else { Optional.empty() } - val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) + val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterAttributeValuePair.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterAttributeValuePair.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterAttributeValuePair.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterAttributeValuePair.kt index df599d883e82ca..b64a49bfb3c025 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterAttributeValuePair.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterExtensionFieldSet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterExtensionFieldSet.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterExtensionFieldSet.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterExtensionFieldSet.kt index 88d60856d7460b..24f21fcdbcf814 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterExtensionFieldSet.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterSceneInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterSceneInfoStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterSceneInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterSceneInfoStruct.kt index 7d21ccd8c87802..a77c286d44f563 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesClusterSceneInfoStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index c5f2429f4af83b..b8f67a51a60beb 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index 14c27a55df4da9..d1c115ff44e58e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index 5f93367f7ea4e3..597fce1f35e644 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index 001698e66b5dce..c3fc752f705a55 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index 7aa8d606fbcc21..8babb9d7bc1680 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index 58a9599025b985..21bfbb8c4e950c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index 313ac3dda11319..720cdd6c854a72 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index a3b6fd3d55188f..b74d29b91fbebe 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index 152f42081f7ab8..6681fb2948b29b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt similarity index 96% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index 4dd53317007f70..ac2e8efd626715 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index 034d6d0d7e21e3..4e966f6c36021e 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index 546255c64a2d1b..b308907db2a90c 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt index 0891c3106fbadf..d1bb92e17a739b 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt similarity index 97% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt index b22100fdf31dda..3e58a31e5c24f3 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index 5098411f07e58d..719fc4459ca37f 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -34,9 +34,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( val nullableStruct: UnitTestingClusterSimpleStruct?, val optionalStruct: Optional, val nullableOptionalStruct: Optional?, - val nullableList: List?, - val optionalList: Optional>, - val nullableOptionalList: Optional>? + val nullableList: List?, + val optionalList: Optional>, + val nullableOptionalList: Optional>? ) { override fun toString(): String = buildString { append("UnitTestingClusterNullablesAndOptionalsStruct {\n") @@ -242,10 +242,10 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } val nullableList = if (!tlvReader.isNull()) { - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } @@ -256,10 +256,10 @@ class UnitTestingClusterNullablesAndOptionalsStruct( val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { Optional.of( - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } @@ -271,10 +271,10 @@ class UnitTestingClusterNullablesAndOptionalsStruct( if (!tlvReader.isNull()) { if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { Optional.of( - buildList { + buildList { tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + add(tlvReader.getUByte(AnonymousTag)) } tlvReader.exitContainer() } diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt similarity index 91% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 4c1dfe9e93b76e..7266ca0054d7d8 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -25,10 +25,10 @@ import matter.tlv.TlvWriter class UnitTestingClusterSimpleStruct( val a: UByte, val b: Boolean, - val c: UInt, + val c: UByte, val d: ByteArray, val e: String, - val f: UInt, + val f: UByte, val g: Float, val h: Double ) { @@ -74,10 +74,10 @@ class UnitTestingClusterSimpleStruct( tlvReader.enterStructure(tlvTag) val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) - val c = tlvReader.getUInt(ContextSpecificTag(TAG_C)) + val c = tlvReader.getUByte(ContextSpecificTag(TAG_C)) val d = tlvReader.getByteArray(ContextSpecificTag(TAG_D)) val e = tlvReader.getString(ContextSpecificTag(TAG_E)) - val f = tlvReader.getUInt(ContextSpecificTag(TAG_F)) + val f = tlvReader.getUByte(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt similarity index 98% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 0fae66d5d86dc0..4e4b00571da5d9 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs import java.util.Optional -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 9e49970a89db9c..9a7f7d3ba58b08 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt similarity index 95% rename from src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt rename to src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt index ffc34fe8515c2c..8840aec05a78bd 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.structs +package matter.controller.cluster.structs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccessControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccessControlCluster.kt deleted file mode 100644 index 78ee6725bb7646..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccessControlCluster.kt +++ /dev/null @@ -1,180 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class AccessControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AclAttribute(val value: List) - - class ExtensionAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readAclAttribute(): AclAttribute { - // Implementation needs to be added here - } - - suspend fun readAclAttributeWithFabricFilter(isFabricFiltered: Boolean): AclAttribute { - // Implementation needs to be added here - } - - suspend fun writeAclAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAclAttribute(minInterval: Int, maxInterval: Int): AclAttribute { - // Implementation needs to be added here - } - - suspend fun readExtensionAttribute(): ExtensionAttribute { - // Implementation needs to be added here - } - - suspend fun readExtensionAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): ExtensionAttribute { - // Implementation needs to be added here - } - - suspend fun writeExtensionAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeExtensionAttribute(minInterval: Int, maxInterval: Int): ExtensionAttribute { - // Implementation needs to be added here - } - - suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeSubjectsPerAccessControlEntryAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readTargetsPerAccessControlEntryAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeTargetsPerAccessControlEntryAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readAccessControlEntriesPerFabricAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAccessControlEntriesPerFabricAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 31u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccountLoginCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccountLoginCluster.kt deleted file mode 100644 index e11860c0ea53d2..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccountLoginCluster.kt +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class AccountLoginCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GetSetupPINResponse(val setupPIN: String) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun getSetupPIN( - tempAccountIdentifier: String, - timedInvokeTimeoutMs: Int - ): GetSetupPINResponse { - val commandId = 0L - - // Implementation needs to be added here - } - - suspend fun login( - tempAccountIdentifier: String, - setupPIN: String, - node: ULong?, - timedInvokeTimeoutMs: Int - ) { - val commandId = 2L - - // Implementation needs to be added here - } - - suspend fun logout(node: ULong?, timedInvokeTimeoutMs: Int) { - val commandId = 3L - - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1294u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActionsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActionsCluster.kt deleted file mode 100644 index 264bde16fae360..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActionsCluster.kt +++ /dev/null @@ -1,271 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) { - class ActionListAttribute(val value: List) - - class EndpointListsAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun instantAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun instantActionWithTransition( - actionID: UShort, - invokeID: UInt?, - transitionTime: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun startActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun pauseActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resumeAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enableActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun disableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 10L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun disableActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 11L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readActionListAttribute(): ActionListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActionListAttribute( - minInterval: Int, - maxInterval: Int - ): ActionListAttribute { - // Implementation needs to be added here - } - - suspend fun readEndpointListsAttribute(): EndpointListsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEndpointListsAttribute( - minInterval: Int, - maxInterval: Int - ): EndpointListsAttribute { - // Implementation needs to be added here - } - - suspend fun readSetupURLAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeSetupURLAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 37u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt deleted file mode 100644 index 9b128e71667096..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt +++ /dev/null @@ -1,173 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ActivatedCarbonFilterMonitoringCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LastChangedTimeAttribute(val value: UInt?) - - class ReplacementProductListAttribute( - val value: List? - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun resetCondition(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readConditionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeConditionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDegradationDirectionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeDegradationDirectionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readChangeIndicationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeChangeIndicationAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readInPlaceIndicatorAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeInPlaceIndicatorAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { - // Implementation needs to be added here - } - - suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLastChangedTimeAttribute( - minInterval: Int, - maxInterval: Int - ): LastChangedTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeReplacementProductListAttribute( - minInterval: Int, - maxInterval: Int - ): ReplacementProductListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 114u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AdministratorCommissioningCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AdministratorCommissioningCluster.kt deleted file mode 100644 index fa3698f95ac7e6..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AdministratorCommissioningCluster.kt +++ /dev/null @@ -1,157 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class AdministratorCommissioningCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AdminFabricIndexAttribute(val value: UByte?) - - class AdminVendorIdAttribute(val value: UShort?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun openCommissioningWindow( - commissioningTimeout: UShort, - PAKEPasscodeVerifier: ByteArray, - discriminator: UShort, - iterations: UInt, - salt: ByteArray, - timedInvokeTimeoutMs: Int - ) { - val commandId = 0L - - // Implementation needs to be added here - } - - suspend fun openBasicCommissioningWindow( - commissioningTimeout: UShort, - timedInvokeTimeoutMs: Int - ) { - val commandId = 1L - - // Implementation needs to be added here - } - - suspend fun revokeCommissioning(timedInvokeTimeoutMs: Int) { - val commandId = 2L - - // Implementation needs to be added here - } - - suspend fun readWindowStatusAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeWindowStatusAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAdminFabricIndexAttribute( - minInterval: Int, - maxInterval: Int - ): AdminFabricIndexAttribute { - // Implementation needs to be added here - } - - suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAdminVendorIdAttribute( - minInterval: Int, - maxInterval: Int - ): AdminVendorIdAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 60u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AirQualityCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AirQualityCluster.kt deleted file mode 100644 index 6355856efbd286..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AirQualityCluster.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readAirQualityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeAirQualityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 91u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationBasicCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationBasicCluster.kt deleted file mode 100644 index 58b400775a3fea..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationBasicCluster.kt +++ /dev/null @@ -1,169 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ApplicationBasicCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ApplicationAttribute(val value: ApplicationBasicClusterApplicationStruct) - - class AllowedVendorListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readVendorNameAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeVendorNameAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readVendorIDAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeVendorIDAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readApplicationNameAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeApplicationNameAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductIDAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeProductIDAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readApplicationAttribute(): ApplicationAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeApplicationAttribute( - minInterval: Int, - maxInterval: Int - ): ApplicationAttribute { - // Implementation needs to be added here - } - - suspend fun readStatusAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeStatusAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readApplicationVersionAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeApplicationVersionAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAllowedVendorListAttribute( - minInterval: Int, - maxInterval: Int - ): AllowedVendorListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1293u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationLauncherCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationLauncherCluster.kt deleted file mode 100644 index cd1fb69aa46af3..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationLauncherCluster.kt +++ /dev/null @@ -1,163 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ApplicationLauncherCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LauncherResponse(val status: UInt, val data: ByteArray?) - - class CatalogListAttribute(val value: List?) - - class CurrentAppAttribute(val value: ApplicationLauncherClusterApplicationEPStruct?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun launchApp( - application: ApplicationLauncherClusterApplicationStruct?, - data: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): LauncherResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stopApp( - application: ApplicationLauncherClusterApplicationStruct?, - timedInvokeTimeoutMs: Int? = null - ): LauncherResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun hideApp( - application: ApplicationLauncherClusterApplicationStruct?, - timedInvokeTimeoutMs: Int? = null - ): LauncherResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readCatalogListAttribute(): CatalogListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCatalogListAttribute( - minInterval: Int, - maxInterval: Int - ): CatalogListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentAppAttribute(): CurrentAppAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentAppAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentAppAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1292u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AudioOutputCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AudioOutputCluster.kt deleted file mode 100644 index e90ee1bd52ce00..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AudioOutputCluster.kt +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) { - class OutputListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun selectOutput(index: UByte, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun renameOutput(index: UByte, name: String, timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readOutputListAttribute(): OutputListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOutputListAttribute( - minInterval: Int, - maxInterval: Int - ): OutputListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentOutputAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentOutputAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1291u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BallastConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BallastConfigurationCluster.kt deleted file mode 100644 index c3a9d6c78807eb..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BallastConfigurationCluster.kt +++ /dev/null @@ -1,315 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BallastConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class IntrinsicBallastFactorAttribute(val value: UByte?) - - class BallastFactorAdjustmentAttribute(val value: UByte?) - - class LampRatedHoursAttribute(val value: UInt?) - - class LampBurnHoursAttribute(val value: UInt?) - - class LampBurnHoursTripPointAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readPhysicalMinLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePhysicalMinLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readPhysicalMaxLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePhysicalMaxLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBallastStatusAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBallastStatusAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMinLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeMinLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMinLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMaxLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeMaxLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMaxLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute { - // Implementation needs to be added here - } - - suspend fun writeIntrinsicBallastFactorAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeIntrinsicBallastFactorAttribute( - minInterval: Int, - maxInterval: Int - ): IntrinsicBallastFactorAttribute { - // Implementation needs to be added here - } - - suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute { - // Implementation needs to be added here - } - - suspend fun writeBallastFactorAdjustmentAttribute( - value: UByte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBallastFactorAdjustmentAttribute( - minInterval: Int, - maxInterval: Int - ): BallastFactorAdjustmentAttribute { - // Implementation needs to be added here - } - - suspend fun readLampQuantityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLampQuantityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLampTypeAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeLampTypeAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLampTypeAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLampManufacturerAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeLampManufacturerAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLampManufacturerAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute { - // Implementation needs to be added here - } - - suspend fun writeLampRatedHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLampRatedHoursAttribute( - minInterval: Int, - maxInterval: Int - ): LampRatedHoursAttribute { - // Implementation needs to be added here - } - - suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute { - // Implementation needs to be added here - } - - suspend fun writeLampBurnHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLampBurnHoursAttribute( - minInterval: Int, - maxInterval: Int - ): LampBurnHoursAttribute { - // Implementation needs to be added here - } - - suspend fun readLampAlarmModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeLampAlarmModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLampAlarmModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute { - // Implementation needs to be added here - } - - suspend fun writeLampBurnHoursTripPointAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLampBurnHoursTripPointAttribute( - minInterval: Int, - maxInterval: Int - ): LampBurnHoursTripPointAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 769u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BarrierControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BarrierControlCluster.kt deleted file mode 100644 index e3446f20394a8e..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BarrierControlCluster.kt +++ /dev/null @@ -1,255 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BarrierControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun barrierControlGoToPercent(percentOpen: UByte, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun barrierControlStop(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readBarrierMovingStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBarrierMovingStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBarrierSafetyStatusAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeBarrierSafetyStatusAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierCapabilitiesAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBarrierCapabilitiesAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBarrierOpenEventsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBarrierOpenEventsAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBarrierOpenEventsAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierCloseEventsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBarrierCloseEventsAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBarrierCloseEventsAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierCommandOpenEventsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBarrierCommandOpenEventsAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBarrierCommandOpenEventsAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierCommandCloseEventsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBarrierCommandCloseEventsAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBarrierCommandCloseEventsAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierOpenPeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBarrierOpenPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBarrierOpenPeriodAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierClosePeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBarrierClosePeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBarrierClosePeriodAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBarrierPositionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBarrierPositionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 259u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BasicInformationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BasicInformationCluster.kt deleted file mode 100644 index 9cfb4657ad3cc0..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BasicInformationCluster.kt +++ /dev/null @@ -1,329 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BasicInformationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class CapabilityMinimaAttribute(val value: BasicInformationClusterCapabilityMinimaStruct) - - class ProductAppearanceAttribute(val value: BasicInformationClusterProductAppearanceStruct?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun mfgSpecificPing(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readDataModelRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDataModelRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readVendorNameAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeVendorNameAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readVendorIDAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeVendorIDAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readProductNameAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeProductNameAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductIDAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeProductIDAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readNodeLabelAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNodeLabelAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLocationAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeLocationAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLocationAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readHardwareVersionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeHardwareVersionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readHardwareVersionStringAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeHardwareVersionStringAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readSoftwareVersionAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSoftwareVersionAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readSoftwareVersionStringAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeSoftwareVersionStringAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readManufacturingDateAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeManufacturingDateAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readPartNumberAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribePartNumberAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductURLAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeProductURLAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductLabelAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeProductLabelAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readSerialNumberAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeSerialNumberAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLocalConfigDisabledAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeLocalConfigDisabledAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLocalConfigDisabledAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readReachableAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeReachableAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readUniqueIDAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeUniqueIDAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCapabilityMinimaAttribute( - minInterval: Int, - maxInterval: Int - ): CapabilityMinimaAttribute { - // Implementation needs to be added here - } - - suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeProductAppearanceAttribute( - minInterval: Int, - maxInterval: Int - ): ProductAppearanceAttribute { - // Implementation needs to be added here - } - - suspend fun readSpecificationVersionAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSpecificationVersionAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readMaxPathsPerInvokeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeMaxPathsPerInvokeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 40u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BinaryInputBasicCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BinaryInputBasicCluster.kt deleted file mode 100644 index a8da4754e7748f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BinaryInputBasicCluster.kt +++ /dev/null @@ -1,215 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BinaryInputBasicCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readActiveTextAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeActiveTextAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeActiveTextAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readDescriptionAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeDescriptionAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDescriptionAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readInactiveTextAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeInactiveTextAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInactiveTextAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readOutOfServiceAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeOutOfServiceAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOutOfServiceAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readPolarityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePolarityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readPresentValueAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writePresentValueAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePresentValueAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readReliabilityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeReliabilityAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeReliabilityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStatusFlagsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeStatusFlagsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readApplicationTypeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeApplicationTypeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 15u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BindingCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BindingCluster.kt deleted file mode 100644 index 824522c0a95f7d..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BindingCluster.kt +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BindingCluster(private val controller: MatterController, private val endpointId: UShort) { - class BindingAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readBindingAttribute(): BindingAttribute { - // Implementation needs to be added here - } - - suspend fun readBindingAttributeWithFabricFilter(isFabricFiltered: Boolean): BindingAttribute { - // Implementation needs to be added here - } - - suspend fun writeBindingAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBindingAttribute(minInterval: Int, maxInterval: Int): BindingAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 30u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanSensorConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanSensorConfigurationCluster.kt deleted file mode 100644 index 068aa709815206..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanSensorConfigurationCluster.kt +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BooleanSensorConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun suppressRequest(alarmsToSuppress: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSensitivityLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeSensitivityLevelAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSensitivityLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAlarmsActiveAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeAlarmsActiveAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAlarmsSuppressedAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeAlarmsSuppressedAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAlarmsEnabledAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeAlarmsEnabledAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAlarmsEnabledAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 128u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanStateCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanStateCluster.kt deleted file mode 100644 index f8b8fa301c2ee1..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanStateCluster.kt +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BooleanStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readStateValueAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeStateValueAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 69u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt deleted file mode 100644 index 6f16251fb84c31..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt +++ /dev/null @@ -1,244 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class BridgedDeviceBasicInformationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ProductAppearanceAttribute( - val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readVendorNameAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeVendorNameAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readVendorIDAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeVendorIDAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readProductNameAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeProductNameAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readNodeLabelAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNodeLabelAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readHardwareVersionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeHardwareVersionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readHardwareVersionStringAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeHardwareVersionStringAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readSoftwareVersionAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSoftwareVersionAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readSoftwareVersionStringAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeSoftwareVersionStringAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readManufacturingDateAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeManufacturingDateAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readPartNumberAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribePartNumberAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductURLAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeProductURLAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductLabelAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeProductLabelAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readSerialNumberAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeSerialNumberAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readReachableAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeReachableAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readUniqueIDAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeUniqueIDAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeProductAppearanceAttribute( - minInterval: Int, - maxInterval: Int - ): ProductAppearanceAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 57u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt deleted file mode 100644 index 9586beac02dbcc..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class CarbonDioxideConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1037u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt deleted file mode 100644 index fdb299760ce83a..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class CarbonMonoxideConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1036u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ChannelCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ChannelCluster.kt deleted file mode 100644 index 5396dd327550bd..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ChannelCluster.kt +++ /dev/null @@ -1,223 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ChannelCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeChannelResponse(val status: UInt, val data: String?) - - class ProgramGuideResponse( - val channelPagingStruct: Short, - val programList: List - ) - - class ChannelListAttribute(val value: List?) - - class LineupAttribute(val value: ChannelClusterLineupInfoStruct?) - - class CurrentChannelAttribute(val value: ChannelClusterChannelInfoStruct?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeChannel( - match: String, - timedInvokeTimeoutMs: Int? = null - ): ChangeChannelResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun changeChannelByNumber( - majorNumber: UShort, - minorNumber: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun skipChannel(count: Short, timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getProgramGuide( - startTime: UInt?, - endTime: UInt?, - channelList: List?, - pageToken: ChannelClusterPageTokenStruct?, - recordingFlag: ULong?, - externalIDList: List?, - data: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): ProgramGuideResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun recordProgram( - programIdentifier: String, - shouldRecordSeries: Boolean, - externalIDList: List, - data: ByteArray, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun cancelRecordProgram( - programIdentifier: String, - shouldRecordSeries: Boolean, - externalIDList: List, - data: ByteArray, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readChannelListAttribute(): ChannelListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeChannelListAttribute( - minInterval: Int, - maxInterval: Int - ): ChannelListAttribute { - // Implementation needs to be added here - } - - suspend fun readLineupAttribute(): LineupAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLineupAttribute(minInterval: Int, maxInterval: Int): LineupAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentChannelAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentChannelAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1284u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ColorControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ColorControlCluster.kt deleted file mode 100644 index 1f30a7e219f96f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ColorControlCluster.kt +++ /dev/null @@ -1,1007 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ColorControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class NumberOfPrimariesAttribute(val value: UByte?) - - class Primary1IntensityAttribute(val value: UByte?) - - class Primary2IntensityAttribute(val value: UByte?) - - class Primary3IntensityAttribute(val value: UByte?) - - class Primary4IntensityAttribute(val value: UByte?) - - class Primary5IntensityAttribute(val value: UByte?) - - class Primary6IntensityAttribute(val value: UByte?) - - class ColorPointRIntensityAttribute(val value: UByte?) - - class ColorPointGIntensityAttribute(val value: UByte?) - - class ColorPointBIntensityAttribute(val value: UByte?) - - class StartUpColorTemperatureMiredsAttribute(val value: UShort?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun moveToHue( - hue: UByte, - direction: UInt, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveHue( - moveMode: UInt, - rate: UByte, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stepHue( - stepMode: UInt, - stepSize: UByte, - transitionTime: UByte, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveToSaturation( - saturation: UByte, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveSaturation( - moveMode: UInt, - rate: UByte, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stepSaturation( - stepMode: UInt, - stepSize: UByte, - transitionTime: UByte, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveToHueAndSaturation( - hue: UByte, - saturation: UByte, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveToColor( - colorX: UShort, - colorY: UShort, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveColor( - rateX: Short, - rateY: Short, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stepColor( - stepX: Short, - stepY: Short, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveToColorTemperature( - colorTemperatureMireds: UShort, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 10L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enhancedMoveToHue( - enhancedHue: UShort, - direction: UInt, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 64L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enhancedMoveHue( - moveMode: UInt, - rate: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 65L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enhancedStepHue( - stepMode: UInt, - stepSize: UShort, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 66L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enhancedMoveToHueAndSaturation( - enhancedHue: UShort, - saturation: UByte, - transitionTime: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 67L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun colorLoopSet( - updateFlags: UInt, - action: UInt, - direction: UInt, - time: UShort, - startHue: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 68L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stopMoveStep( - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 71L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveColorTemperature( - moveMode: UInt, - rate: UShort, - colorTemperatureMinimumMireds: UShort, - colorTemperatureMaximumMireds: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 75L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stepColorTemperature( - stepMode: UInt, - stepSize: UShort, - transitionTime: UShort, - colorTemperatureMinimumMireds: UShort, - colorTemperatureMaximumMireds: UShort, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 76L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readCurrentHueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentHueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentSaturationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentSaturationAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readRemainingTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRemainingTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readCurrentXAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentXAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readCurrentYAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentYAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readDriftCompensationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeDriftCompensationAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCompensationTextAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeCompensationTextAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readColorTemperatureMiredsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorTemperatureMiredsAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeColorModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOptionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeOptionsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOptionsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfPrimariesAttribute( - minInterval: Int, - maxInterval: Int - ): NumberOfPrimariesAttribute { - // Implementation needs to be added here - } - - suspend fun readPrimary1XAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary1XAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary1YAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary1YAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePrimary1IntensityAttribute( - minInterval: Int, - maxInterval: Int - ): Primary1IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readPrimary2XAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary2XAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary2YAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary2YAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePrimary2IntensityAttribute( - minInterval: Int, - maxInterval: Int - ): Primary2IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readPrimary3XAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary3XAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary3YAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary3YAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePrimary3IntensityAttribute( - minInterval: Int, - maxInterval: Int - ): Primary3IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readPrimary4XAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary4XAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary4YAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary4YAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePrimary4IntensityAttribute( - minInterval: Int, - maxInterval: Int - ): Primary4IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readPrimary5XAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary5XAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary5YAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary5YAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePrimary5IntensityAttribute( - minInterval: Int, - maxInterval: Int - ): Primary5IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readPrimary6XAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary6XAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary6YAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePrimary6YAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePrimary6IntensityAttribute( - minInterval: Int, - maxInterval: Int - ): Primary6IntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readWhitePointXAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeWhitePointXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeWhitePointXAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readWhitePointYAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeWhitePointYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeWhitePointYAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointRXAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeColorPointRXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointRXAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointRYAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeColorPointRYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointRYAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { - // Implementation needs to be added here - } - - suspend fun writeColorPointRIntensityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointRIntensityAttribute( - minInterval: Int, - maxInterval: Int - ): ColorPointRIntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readColorPointGXAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeColorPointGXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointGXAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointGYAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeColorPointGYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointGYAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { - // Implementation needs to be added here - } - - suspend fun writeColorPointGIntensityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointGIntensityAttribute( - minInterval: Int, - maxInterval: Int - ): ColorPointGIntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readColorPointBXAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeColorPointBXAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointBXAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointBYAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeColorPointBYAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointBYAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { - // Implementation needs to be added here - } - - suspend fun writeColorPointBIntensityAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeColorPointBIntensityAttribute( - minInterval: Int, - maxInterval: Int - ): ColorPointBIntensityAttribute { - // Implementation needs to be added here - } - - suspend fun readEnhancedCurrentHueAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeEnhancedCurrentHueAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readEnhancedColorModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeEnhancedColorModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readColorLoopActiveAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeColorLoopActiveAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readColorLoopDirectionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeColorLoopDirectionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readColorLoopTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorLoopTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorLoopStartEnhancedHueAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorLoopStartEnhancedHueAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorLoopStoredEnhancedHueAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readColorCapabilitiesAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorCapabilitiesAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorTempPhysicalMinMiredsAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeColorTempPhysicalMaxMiredsAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeCoupleColorTempToLevelMinMiredsAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpColorTemperatureMiredsAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpColorTemperatureMiredsAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpColorTemperatureMiredsAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 768u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentAppObserverCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentAppObserverCluster.kt deleted file mode 100644 index 8c7f94fb3b3d99..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentAppObserverCluster.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ContentAppObserverCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ContentAppMessageResponse(val status: UInt?, val data: String, val encodingHint: String) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun contentAppMessage( - data: String?, - encodingHint: String, - timedInvokeTimeoutMs: Int? = null - ): ContentAppMessageResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1296u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentControlCluster.kt deleted file mode 100644 index 16a9d6dfbfa009..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentControlCluster.kt +++ /dev/null @@ -1,280 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ContentControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ResetPINResponse(val PINCode: String) - - class OnDemandRatingsAttribute(val value: List?) - - class ScheduledContentRatingsAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun updatePIN(oldPIN: String?, newPIN: String, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resetPIN(timedInvokeTimeoutMs: Int? = null): ResetPINResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enable(timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun disable(timedInvokeTimeoutMs: Int? = null) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addBonusTime(PINCode: String?, bonusTime: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setScreenDailyTime(screenTime: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun blockUnratedContent(timedInvokeTimeoutMs: Int? = null) { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun unblockUnratedContent(timedInvokeTimeoutMs: Int? = null) { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setOnDemandRatingThreshold(rating: String, timedInvokeTimeoutMs: Int? = null) { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setScheduledContentRatingThreshold( - rating: String, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 10L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readEnabledAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeEnabledAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOnDemandRatingsAttribute( - minInterval: Int, - maxInterval: Int - ): OnDemandRatingsAttribute { - // Implementation needs to be added here - } - - suspend fun readOnDemandRatingThresholdAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeOnDemandRatingThresholdAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeScheduledContentRatingsAttribute( - minInterval: Int, - maxInterval: Int - ): ScheduledContentRatingsAttribute { - // Implementation needs to be added here - } - - suspend fun readScheduledContentRatingThresholdAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeScheduledContentRatingThresholdAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readScreenDailyTimeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeScreenDailyTimeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRemainingScreenTimeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRemainingScreenTimeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readBlockUnratedAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeBlockUnratedAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1295u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentLauncherCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentLauncherCluster.kt deleted file mode 100644 index 5db8509ec6034d..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentLauncherCluster.kt +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ContentLauncherCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LauncherResponse(val status: UInt, val data: String?) - - class AcceptHeaderAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun launchContent( - search: ContentLauncherClusterContentSearchStruct, - autoPlay: Boolean, - data: String?, - playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct?, - useCurrentContext: Boolean?, - timedInvokeTimeoutMs: Int? = null - ): LauncherResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun launchURL( - contentURL: String, - displayString: String?, - brandingInformation: ContentLauncherClusterBrandingInformationStruct?, - timedInvokeTimeoutMs: Int? = null - ): LauncherResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptHeaderAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptHeaderAttribute { - // Implementation needs to be added here - } - - suspend fun readSupportedStreamingProtocolsAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedStreamingProtocolsAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1290u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DemandResponseLoadControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DemandResponseLoadControlCluster.kt deleted file mode 100644 index 2f61d6f7b0c5db..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DemandResponseLoadControlCluster.kt +++ /dev/null @@ -1,260 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DemandResponseLoadControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LoadControlProgramsAttribute( - val value: List - ) - - class EventsAttribute(val value: List) - - class ActiveEventsAttribute( - val value: List - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun registerLoadControlProgramRequest( - loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun unregisterLoadControlProgramRequest( - loadControlProgramID: ByteArray, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addLoadControlEventRequest( - event: DemandResponseLoadControlClusterLoadControlEventStruct, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeLoadControlEventRequest( - eventID: ByteArray, - cancelControl: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearLoadControlEventsRequest(timedInvokeTimeoutMs: Int? = null) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLoadControlProgramsAttribute( - minInterval: Int, - maxInterval: Int - ): LoadControlProgramsAttribute { - // Implementation needs to be added here - } - - suspend fun readNumberOfLoadControlProgramsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfLoadControlProgramsAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readEventsAttribute(): EventsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventsAttribute(minInterval: Int, maxInterval: Int): EventsAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveEventsAttribute(): ActiveEventsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveEventsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveEventsAttribute { - // Implementation needs to be added here - } - - suspend fun readNumberOfEventsPerProgramAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfEventsPerProgramAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfTransitionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfTransitionsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDefaultRandomStartAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeDefaultRandomStartAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDefaultRandomStartAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDefaultRandomDurationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeDefaultRandomDurationAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDefaultRandomDurationAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 150u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DescriptorCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DescriptorCluster.kt deleted file mode 100644 index 109cefa90c030a..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DescriptorCluster.kt +++ /dev/null @@ -1,151 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) { - class DeviceTypeListAttribute(val value: List) - - class ServerListAttribute(val value: List) - - class ClientListAttribute(val value: List) - - class PartsListAttribute(val value: List) - - class TagListAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDeviceTypeListAttribute( - minInterval: Int, - maxInterval: Int - ): DeviceTypeListAttribute { - // Implementation needs to be added here - } - - suspend fun readServerListAttribute(): ServerListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeServerListAttribute( - minInterval: Int, - maxInterval: Int - ): ServerListAttribute { - // Implementation needs to be added here - } - - suspend fun readClientListAttribute(): ClientListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeClientListAttribute( - minInterval: Int, - maxInterval: Int - ): ClientListAttribute { - // Implementation needs to be added here - } - - suspend fun readPartsListAttribute(): PartsListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePartsListAttribute(minInterval: Int, maxInterval: Int): PartsListAttribute { - // Implementation needs to be added here - } - - suspend fun readTagListAttribute(): TagListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTagListAttribute(minInterval: Int, maxInterval: Int): TagListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 29u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DeviceEnergyManagementCluster.kt deleted file mode 100644 index 76705026383d83..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DeviceEnergyManagementCluster.kt +++ /dev/null @@ -1,237 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DeviceEnergyManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class PowerAdjustmentCapabilityAttribute( - val value: List? - ) - - class ForecastAttribute(val value: DeviceEnergyManagementClusterForecastStruct?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun powerAdjustRequest(power: Long, duration: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun cancelPowerAdjustRequest(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun startTimeAdjustRequest(requestedStartTime: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun pauseRequest(duration: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resumeRequest(timedInvokeTimeoutMs: Int? = null) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun modifyForecastRequest( - forecastId: UInt, - slotAdjustments: List, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun requestConstraintBasedForecast( - constraints: List, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readESATypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeESATypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readESACanGenerateAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeESACanGenerateAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readESAStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeESAStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAbsMinPowerAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeAbsMinPowerAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readAbsMaxPowerAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeAbsMaxPowerAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePowerAdjustmentCapabilityAttribute( - minInterval: Int, - maxInterval: Int - ): PowerAdjustmentCapabilityAttribute { - // Implementation needs to be added here - } - - suspend fun readForecastAttribute(): ForecastAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeForecastAttribute(minInterval: Int, maxInterval: Int): ForecastAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 152u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DiagnosticLogsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DiagnosticLogsCluster.kt deleted file mode 100644 index 13b9d53a1f6740..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DiagnosticLogsCluster.kt +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DiagnosticLogsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class RetrieveLogsResponse( - val status: UInt, - val logContent: ByteArray, - val UTCTimeStamp: ULong?, - val timeSinceBoot: ULong? - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun retrieveLogsRequest( - intent: UInt, - requestedProtocol: UInt, - transferFileDesignator: String?, - timedInvokeTimeoutMs: Int? = null - ): RetrieveLogsResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 50u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherAlarmCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherAlarmCluster.kt deleted file mode 100644 index e0d986f2c59042..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherAlarmCluster.kt +++ /dev/null @@ -1,147 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DishwasherAlarmCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun reset(alarms: ULong, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun modifyEnabledAlarms(mask: ULong, timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readMaskAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeMaskAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readLatchAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeLatchAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readStateAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeStateAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readSupportedAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 93u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherModeCluster.kt deleted file mode 100644 index 5352d16f02443c..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherModeCluster.kt +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DishwasherModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UInt, val statusText: String?) - - class SupportedModesAttribute(val value: List) - - class StartUpModeAttribute(val value: UByte?) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeoutMs: Int? = null - ): ChangeToModeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpModeAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 89u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DoorLockCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DoorLockCluster.kt deleted file mode 100644 index efe90d407177d7..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DoorLockCluster.kt +++ /dev/null @@ -1,866 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class DoorLockCluster(private val controller: MatterController, private val endpointId: UShort) { - class GetWeekDayScheduleResponse( - val weekDayIndex: UByte, - val userIndex: UShort, - val status: UInt, - val daysMask: UInt?, - val startHour: UByte?, - val startMinute: UByte?, - val endHour: UByte?, - val endMinute: UByte? - ) - - class GetYearDayScheduleResponse( - val yearDayIndex: UByte, - val userIndex: UShort, - val status: UInt, - val localStartTime: UInt?, - val localEndTime: UInt? - ) - - class GetHolidayScheduleResponse( - val holidayIndex: UByte, - val status: UInt, - val localStartTime: UInt?, - val localEndTime: UInt?, - val operatingMode: UInt? - ) - - class GetUserResponse( - val userIndex: UShort, - val userName: String?, - val userUniqueID: UInt?, - val userStatus: UInt?, - val userType: UInt?, - val credentialRule: UInt?, - val credentials: List?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, - val nextUserIndex: UShort? - ) - - class SetCredentialResponse( - val status: UInt, - val userIndex: UShort?, - val nextCredentialIndex: UShort? - ) - - class GetCredentialStatusResponse( - val credentialExists: Boolean, - val userIndex: UShort?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, - val nextCredentialIndex: UShort? - ) - - class LockStateAttribute(val value: UInt?) - - class DoorStateAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun lockDoor(PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { - val commandId = 0L - - // Implementation needs to be added here - } - - suspend fun unlockDoor(PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { - val commandId = 1L - - // Implementation needs to be added here - } - - suspend fun unlockWithTimeout(timeout: UShort, PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { - val commandId = 3L - - // Implementation needs to be added here - } - - suspend fun setWeekDaySchedule( - weekDayIndex: UByte, - userIndex: UShort, - daysMask: UInt, - startHour: UByte, - startMinute: UByte, - endHour: UByte, - endMinute: UByte, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 11L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getWeekDaySchedule( - weekDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeoutMs: Int? = null - ): GetWeekDayScheduleResponse { - val commandId = 12L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearWeekDaySchedule( - weekDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 13L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setYearDaySchedule( - yearDayIndex: UByte, - userIndex: UShort, - localStartTime: UInt, - localEndTime: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 14L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getYearDaySchedule( - yearDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeoutMs: Int? = null - ): GetYearDayScheduleResponse { - val commandId = 15L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearYearDaySchedule( - yearDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 16L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setHolidaySchedule( - holidayIndex: UByte, - localStartTime: UInt, - localEndTime: UInt, - operatingMode: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 17L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getHolidaySchedule( - holidayIndex: UByte, - timedInvokeTimeoutMs: Int? = null - ): GetHolidayScheduleResponse { - val commandId = 18L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearHolidaySchedule(holidayIndex: UByte, timedInvokeTimeoutMs: Int? = null) { - val commandId = 19L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setUser( - operationType: UInt, - userIndex: UShort, - userName: String?, - userUniqueID: UInt?, - userStatus: UInt?, - userType: UInt?, - credentialRule: UInt?, - timedInvokeTimeoutMs: Int - ) { - val commandId = 26L - - // Implementation needs to be added here - } - - suspend fun getUser(userIndex: UShort, timedInvokeTimeoutMs: Int? = null): GetUserResponse { - val commandId = 27L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearUser(userIndex: UShort, timedInvokeTimeoutMs: Int) { - val commandId = 29L - - // Implementation needs to be added here - } - - suspend fun setCredential( - operationType: UInt, - credential: DoorLockClusterCredentialStruct, - credentialData: ByteArray, - userIndex: UShort?, - userStatus: UInt?, - userType: UInt?, - timedInvokeTimeoutMs: Int - ): SetCredentialResponse { - val commandId = 34L - - // Implementation needs to be added here - } - - suspend fun getCredentialStatus( - credential: DoorLockClusterCredentialStruct, - timedInvokeTimeoutMs: Int? = null - ): GetCredentialStatusResponse { - val commandId = 36L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearCredential( - credential: DoorLockClusterCredentialStruct?, - timedInvokeTimeoutMs: Int - ) { - val commandId = 38L - - // Implementation needs to be added here - } - - suspend fun unboltDoor(PINCode: ByteArray?, timedInvokeTimeoutMs: Int) { - val commandId = 39L - - // Implementation needs to be added here - } - - suspend fun readLockStateAttribute(): LockStateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLockStateAttribute(minInterval: Int, maxInterval: Int): LockStateAttribute { - // Implementation needs to be added here - } - - suspend fun readLockTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLockTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readActuatorEnabledAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeActuatorEnabledAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readDoorStateAttribute(): DoorStateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDoorStateAttribute(minInterval: Int, maxInterval: Int): DoorStateAttribute { - // Implementation needs to be added here - } - - suspend fun readDoorOpenEventsAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeDoorOpenEventsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDoorOpenEventsAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readDoorClosedEventsAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeDoorClosedEventsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDoorClosedEventsAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readOpenPeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeOpenPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOpenPeriodAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfTotalUsersSupportedAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readNumberOfPINUsersSupportedAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfPINUsersSupportedAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfRFIDUsersSupportedAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfWeekDaySchedulesSupportedPerUserAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfYearDaySchedulesSupportedPerUserAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfHolidaySchedulesSupportedAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readMaxPINCodeLengthAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMaxPINCodeLengthAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMinPINCodeLengthAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMinPINCodeLengthAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMaxRFIDCodeLengthAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMaxRFIDCodeLengthAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMinRFIDCodeLengthAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMinRFIDCodeLengthAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCredentialRulesSupportAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCredentialRulesSupportAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfCredentialsSupportedPerUserAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readLanguageAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeLanguageAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLanguageAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLEDSettingsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeLEDSettingsAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLEDSettingsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAutoRelockTimeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeAutoRelockTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAutoRelockTimeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readSoundVolumeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeSoundVolumeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSoundVolumeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOperatingModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeOperatingModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOperatingModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSupportedOperatingModesAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedOperatingModesAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readDefaultConfigurationRegisterAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDefaultConfigurationRegisterAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readEnableLocalProgrammingAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeEnableLocalProgrammingAttribute( - value: Boolean, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnableLocalProgrammingAttribute( - minInterval: Int, - maxInterval: Int - ): Boolean { - // Implementation needs to be added here - } - - suspend fun readEnableOneTouchLockingAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeEnableOneTouchLockingAttribute( - value: Boolean, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnableOneTouchLockingAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readEnableInsideStatusLEDAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeEnableInsideStatusLEDAttribute( - value: Boolean, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnableInsideStatusLEDAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readEnablePrivacyModeButtonAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeEnablePrivacyModeButtonAttribute( - value: Boolean, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnablePrivacyModeButtonAttribute( - minInterval: Int, - maxInterval: Int - ): Boolean { - // Implementation needs to be added here - } - - suspend fun readLocalProgrammingFeaturesAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeLocalProgrammingFeaturesAttribute( - value: UInt, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLocalProgrammingFeaturesAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readWrongCodeEntryLimitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeWrongCodeEntryLimitAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeWrongCodeEntryLimitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeUserCodeTemporaryDisableTimeAttribute( - value: UByte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUserCodeTemporaryDisableTimeAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readSendPINOverTheAirAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeSendPINOverTheAirAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSendPINOverTheAirAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readRequirePINforRemoteOperationAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeRequirePINforRemoteOperationAttribute( - value: Boolean, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRequirePINforRemoteOperationAttribute( - minInterval: Int, - maxInterval: Int - ): Boolean { - // Implementation needs to be added here - } - - suspend fun readExpiringUserTimeoutAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeExpiringUserTimeoutAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeExpiringUserTimeoutAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 257u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalMeasurementCluster.kt deleted file mode 100644 index 9e3ed080f8c3f6..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalMeasurementCluster.kt +++ /dev/null @@ -1,1325 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ElectricalMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun getProfileInfoCommand(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getMeasurementProfileCommand( - attributeId: UShort, - startTime: UInt, - numberOfIntervals: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readMeasurementTypeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementTypeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readDcVoltageAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcVoltageAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcVoltageMinAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcVoltageMinAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcVoltageMaxAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcVoltageMaxAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcCurrentAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcCurrentMinAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcCurrentMinAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcCurrentMaxAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcCurrentMaxAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcPowerAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcPowerAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcPowerMinAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcPowerMinAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcPowerMaxAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeDcPowerMaxAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readDcVoltageMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDcVoltageMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readDcVoltageDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDcVoltageDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readDcCurrentMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDcCurrentMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readDcCurrentDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDcCurrentDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readDcPowerMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDcPowerMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readDcPowerDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDcPowerDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcFrequencyAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcFrequencyAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcFrequencyMinAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcFrequencyMinAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcFrequencyMaxAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcFrequencyMaxAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readNeutralCurrentAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeNeutralCurrentAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readTotalActivePowerAttribute(): Int { - // Implementation needs to be added here - } - - suspend fun subscribeTotalActivePowerAttribute(minInterval: Int, maxInterval: Int): Int { - // Implementation needs to be added here - } - - suspend fun readTotalReactivePowerAttribute(): Int { - // Implementation needs to be added here - } - - suspend fun subscribeTotalReactivePowerAttribute(minInterval: Int, maxInterval: Int): Int { - // Implementation needs to be added here - } - - suspend fun readTotalApparentPowerAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTotalApparentPowerAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readMeasured1stHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasured1stHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasured3rdHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasured5thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasured5thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasured7thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasured7thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasured9thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasured9thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasured11thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasured11thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredPhase1stHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredPhase3rdHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredPhase5thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredPhase7thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredPhase9thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredPhase11thHarmonicCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readAcFrequencyMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcFrequencyMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcFrequencyDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcFrequencyDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPowerMultiplierAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePowerMultiplierAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readPowerDivisorAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePowerDivisorAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readHarmonicCurrentMultiplierAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun subscribeHarmonicCurrentMultiplierAttribute( - minInterval: Int, - maxInterval: Int - ): Byte { - // Implementation needs to be added here - } - - suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun subscribePhaseHarmonicCurrentMultiplierAttribute( - minInterval: Int, - maxInterval: Int - ): Byte { - // Implementation needs to be added here - } - - suspend fun readInstantaneousVoltageAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeInstantaneousVoltageAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readInstantaneousLineCurrentAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeInstantaneousLineCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readInstantaneousActiveCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeInstantaneousActiveCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readInstantaneousReactiveCurrentAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeInstantaneousReactiveCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readInstantaneousPowerAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeInstantaneousPowerAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageMinAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageMinAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageMaxAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageMaxAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentMinAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentMinAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentMaxAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentMaxAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readActivePowerAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readActivePowerMinAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerMinAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readActivePowerMaxAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerMaxAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readReactivePowerAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeReactivePowerAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readApparentPowerAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeApparentPowerAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPowerFactorAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun subscribePowerFactorAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeAverageRmsVoltageMeasurementPeriodAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAverageRmsVoltageMeasurementPeriodAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeAverageRmsUnderVoltageCounterAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAverageRmsUnderVoltageCounterAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeRmsExtremeOverVoltagePeriodAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRmsExtremeOverVoltagePeriodAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeRmsExtremeUnderVoltagePeriodAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRmsExtremeUnderVoltagePeriodAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSagPeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeRmsVoltageSagPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRmsVoltageSagPeriodAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSwellPeriodAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeRmsVoltageSwellPeriodAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRmsVoltageSwellPeriodAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcVoltageMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcVoltageMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcVoltageDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcVoltageDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcCurrentMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcCurrentMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcCurrentDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcCurrentDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcPowerMultiplierAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcPowerMultiplierAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcPowerDivisorAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAcPowerDivisorAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readOverloadAlarmsMaskAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeOverloadAlarmsMaskAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOverloadAlarmsMaskAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readVoltageOverloadAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeVoltageOverloadAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readCurrentOverloadAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentOverloadAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAcOverloadAlarmsMaskAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeAcOverloadAlarmsMaskAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAcOverloadAlarmsMaskAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAcVoltageOverloadAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAcVoltageOverloadAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAcCurrentOverloadAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAcCurrentOverloadAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAcActivePowerOverloadAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAcActivePowerOverloadAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAcReactivePowerOverloadAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAcReactivePowerOverloadAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAverageRmsOverVoltageAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsOverVoltageAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAverageRmsUnderVoltageAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsUnderVoltageAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeOverVoltageAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeRmsExtremeOverVoltageAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeUnderVoltageAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeRmsExtremeUnderVoltageAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSagAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageSagAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSwellAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageSwellAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readLineCurrentPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeLineCurrentPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readActiveCurrentPhaseBAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActiveCurrentPhaseBAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readReactiveCurrentPhaseBAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeReactiveCurrentPhaseBAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsVoltagePhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltagePhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageMinPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageMinPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageMaxPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentMinPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentMinPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentMaxPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readActivePowerPhaseBAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerPhaseBAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readActivePowerMinPhaseBAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerMinPhaseBAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readActivePowerMaxPhaseBAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerMaxPhaseBAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readReactivePowerPhaseBAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeReactivePowerPhaseBAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readApparentPowerPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeApparentPowerPhaseBAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPowerFactorPhaseBAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun subscribePowerFactorPhaseBAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsVoltageMeasurementPeriodPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsOverVoltageCounterPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsUnderVoltageCounterPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsExtremeOverVoltagePeriodPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsExtremeUnderVoltagePeriodPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageSagPeriodPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageSwellPeriodPhaseBAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readLineCurrentPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeLineCurrentPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readActiveCurrentPhaseCAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActiveCurrentPhaseCAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readReactiveCurrentPhaseCAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeReactiveCurrentPhaseCAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readRmsVoltagePhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltagePhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageMinPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageMinPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageMaxPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentMinPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentMinPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsCurrentMaxPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readActivePowerPhaseCAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerPhaseCAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readActivePowerMinPhaseCAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerMinPhaseCAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readActivePowerMaxPhaseCAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeActivePowerMaxPhaseCAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readReactivePowerPhaseCAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeReactivePowerPhaseCAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readApparentPowerPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeApparentPowerPhaseCAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPowerFactorPhaseCAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun subscribePowerFactorPhaseCAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsVoltageMeasurementPeriodPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsOverVoltageCounterPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAverageRmsUnderVoltageCounterPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsExtremeOverVoltagePeriodPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsExtremeUnderVoltagePeriodPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageSagPeriodPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRmsVoltageSwellPeriodPhaseCAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 2820u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EnergyEvseCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EnergyEvseCluster.kt deleted file mode 100644 index 8e5208cee1d2b4..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EnergyEvseCluster.kt +++ /dev/null @@ -1,436 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class EnergyEvseCluster(private val controller: MatterController, private val endpointId: UShort) { - class GetTargetsResponse( - val dayOfWeekforSequence: UInt, - val chargingTargets: List - ) - - class StateAttribute(val value: UInt?) - - class ChargingEnabledUntilAttribute(val value: UInt?) - - class DischargingEnabledUntilAttribute(val value: UInt?) - - class NextChargeStartTimeAttribute(val value: UInt?) - - class NextChargeTargetTimeAttribute(val value: UInt?) - - class NextChargeRequiredEnergyAttribute(val value: Long?) - - class NextChargeTargetSoCAttribute(val value: UByte?) - - class ApproximateEVEfficiencyAttribute(val value: UShort?) - - class StateOfChargeAttribute(val value: UByte?) - - class BatteryCapacityAttribute(val value: Long?) - - class VehicleIDAttribute(val value: String?) - - class SessionIDAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun disable(timedInvokeTimeoutMs: Int) { - val commandId = 1L - - // Implementation needs to be added here - } - - suspend fun enableCharging( - chargingEnabledUntil: UInt?, - minimumChargeCurrent: Long, - maximumChargeCurrent: Long, - timedInvokeTimeoutMs: Int - ) { - val commandId = 2L - - // Implementation needs to be added here - } - - suspend fun enableDischarging( - dischargingEnabledUntil: UInt?, - maximumDischargeCurrent: Long, - timedInvokeTimeoutMs: Int - ) { - val commandId = 3L - - // Implementation needs to be added here - } - - suspend fun startDiagnostics(timedInvokeTimeoutMs: Int) { - val commandId = 4L - - // Implementation needs to be added here - } - - suspend fun setTargets( - dayOfWeekforSequence: UInt, - chargingTargets: List, - timedInvokeTimeoutMs: Int - ) { - val commandId = 5L - - // Implementation needs to be added here - } - - suspend fun getTargets(daysToReturn: UInt, timedInvokeTimeoutMs: Int): GetTargetsResponse { - val commandId = 6L - - // Implementation needs to be added here - } - - suspend fun clearTargets(timedInvokeTimeoutMs: Int) { - val commandId = 7L - - // Implementation needs to be added here - } - - suspend fun readStateAttribute(): StateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeStateAttribute(minInterval: Int, maxInterval: Int): StateAttribute { - // Implementation needs to be added here - } - - suspend fun readSupplyStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSupplyStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readFaultStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeFaultStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeChargingEnabledUntilAttribute( - minInterval: Int, - maxInterval: Int - ): ChargingEnabledUntilAttribute { - // Implementation needs to be added here - } - - suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDischargingEnabledUntilAttribute( - minInterval: Int, - maxInterval: Int - ): DischargingEnabledUntilAttribute { - // Implementation needs to be added here - } - - suspend fun readCircuitCapacityAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeCircuitCapacityAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readMinimumChargeCurrentAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeMinimumChargeCurrentAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readMaximumChargeCurrentAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeMaximumChargeCurrentAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readMaximumDischargeCurrentAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeMaximumDischargeCurrentAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readUserMaximumChargeCurrentAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun writeUserMaximumChargeCurrentAttribute( - value: Long, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUserMaximumChargeCurrentAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readRandomizationDelayWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeRandomizationDelayWindowAttribute( - value: UInt, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRandomizationDelayWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readNumberOfWeeklyTargetsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfWeeklyTargetsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfDailyTargetsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfDailyTargetsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNextChargeStartTimeAttribute( - minInterval: Int, - maxInterval: Int - ): NextChargeStartTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNextChargeTargetTimeAttribute( - minInterval: Int, - maxInterval: Int - ): NextChargeTargetTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNextChargeRequiredEnergyAttribute( - minInterval: Int, - maxInterval: Int - ): NextChargeRequiredEnergyAttribute { - // Implementation needs to be added here - } - - suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNextChargeTargetSoCAttribute( - minInterval: Int, - maxInterval: Int - ): NextChargeTargetSoCAttribute { - // Implementation needs to be added here - } - - suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute { - // Implementation needs to be added here - } - - suspend fun writeApproximateEVEfficiencyAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeApproximateEVEfficiencyAttribute( - minInterval: Int, - maxInterval: Int - ): ApproximateEVEfficiencyAttribute { - // Implementation needs to be added here - } - - suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeStateOfChargeAttribute( - minInterval: Int, - maxInterval: Int - ): StateOfChargeAttribute { - // Implementation needs to be added here - } - - suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBatteryCapacityAttribute( - minInterval: Int, - maxInterval: Int - ): BatteryCapacityAttribute { - // Implementation needs to be added here - } - - suspend fun readVehicleIDAttribute(): VehicleIDAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeVehicleIDAttribute(minInterval: Int, maxInterval: Int): VehicleIDAttribute { - // Implementation needs to be added here - } - - suspend fun readSessionIDAttribute(): SessionIDAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSessionIDAttribute(minInterval: Int, maxInterval: Int): SessionIDAttribute { - // Implementation needs to be added here - } - - suspend fun readSessionDurationAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSessionDurationAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readSessionEnergyChargedAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeSessionEnergyChargedAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readSessionEnergyDischargedAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun subscribeSessionEnergyDischargedAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 153u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt deleted file mode 100644 index d7fc8fa494c838..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt +++ /dev/null @@ -1,189 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class EthernetNetworkDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class PHYRateAttribute(val value: UInt?) - - class FullDuplexAttribute(val value: Boolean?) - - class CarrierDetectAttribute(val value: Boolean?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun resetCounts(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readPHYRateAttribute(): PHYRateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePHYRateAttribute(minInterval: Int, maxInterval: Int): PHYRateAttribute { - // Implementation needs to be added here - } - - suspend fun readFullDuplexAttribute(): FullDuplexAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeFullDuplexAttribute( - minInterval: Int, - maxInterval: Int - ): FullDuplexAttribute { - // Implementation needs to be added here - } - - suspend fun readPacketRxCountAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribePacketRxCountAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readPacketTxCountAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribePacketTxCountAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readTxErrCountAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeTxErrCountAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readCollisionCountAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeCollisionCountAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readOverrunCountAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeOverrunCountAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCarrierDetectAttribute( - minInterval: Int, - maxInterval: Int - ): CarrierDetectAttribute { - // Implementation needs to be added here - } - - suspend fun readTimeSinceResetAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeTimeSinceResetAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 55u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FanControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FanControlCluster.kt deleted file mode 100644 index 178dde9600faad..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FanControlCluster.kt +++ /dev/null @@ -1,261 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) { - class PercentSettingAttribute(val value: UByte?) - - class SpeedSettingAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun step( - direction: UInt, - wrap: Boolean?, - lowestOff: Boolean?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readFanModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeFanModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeFanModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readFanModeSequenceAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeFanModeSequenceAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readPercentSettingAttribute(): PercentSettingAttribute { - // Implementation needs to be added here - } - - suspend fun writePercentSettingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePercentSettingAttribute( - minInterval: Int, - maxInterval: Int - ): PercentSettingAttribute { - // Implementation needs to be added here - } - - suspend fun readPercentCurrentAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePercentCurrentAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSpeedMaxAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSpeedMaxAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute { - // Implementation needs to be added here - } - - suspend fun writeSpeedSettingAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSpeedSettingAttribute( - minInterval: Int, - maxInterval: Int - ): SpeedSettingAttribute { - // Implementation needs to be added here - } - - suspend fun readSpeedCurrentAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSpeedCurrentAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readRockSupportAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeRockSupportAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readRockSettingAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeRockSettingAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRockSettingAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readWindSupportAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeWindSupportAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readWindSettingAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeWindSettingAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeWindSettingAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAirflowDirectionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeAirflowDirectionAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeAirflowDirectionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 514u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FaultInjectionCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FaultInjectionCluster.kt deleted file mode 100644 index 8580869b08b912..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FaultInjectionCluster.kt +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class FaultInjectionCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun failAtFault( - type: UInt, - id: UInt, - numCallsToSkip: UInt, - numCallsToFail: UInt, - takeMutex: Boolean, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun failRandomlyAtFault( - type: UInt, - id: UInt, - percentage: UByte, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 4294048774u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FixedLabelCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FixedLabelCluster.kt deleted file mode 100644 index 6d9458b0610c05..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FixedLabelCluster.kt +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) { - class LabelListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readLabelListAttribute(): LabelListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLabelListAttribute(minInterval: Int, maxInterval: Int): LabelListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 64u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FlowMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FlowMeasurementCluster.kt deleted file mode 100644 index 69a553ee21ae62..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FlowMeasurementCluster.kt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class FlowMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: UShort?) - - class MinMeasuredValueAttribute(val value: UShort?) - - class MaxMeasuredValueAttribute(val value: UShort?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readToleranceAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeToleranceAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1028u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt deleted file mode 100644 index 12195781103ef8..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class FormaldehydeConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1067u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralCommissioningCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralCommissioningCluster.kt deleted file mode 100644 index b00a893fde74f8..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralCommissioningCluster.kt +++ /dev/null @@ -1,200 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class GeneralCommissioningCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ArmFailSafeResponse(val errorCode: UInt, val debugText: String) - - class SetRegulatoryConfigResponse(val errorCode: UInt, val debugText: String) - - class CommissioningCompleteResponse(val errorCode: UInt, val debugText: String) - - class BasicCommissioningInfoAttribute( - val value: GeneralCommissioningClusterBasicCommissioningInfo - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun armFailSafe( - expiryLengthSeconds: UShort, - breadcrumb: ULong, - timedInvokeTimeoutMs: Int? = null - ): ArmFailSafeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setRegulatoryConfig( - newRegulatoryConfig: UInt, - countryCode: String, - breadcrumb: ULong, - timedInvokeTimeoutMs: Int? = null - ): SetRegulatoryConfigResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun commissioningComplete( - timedInvokeTimeoutMs: Int? = null - ): CommissioningCompleteResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readBreadcrumbAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeBreadcrumbAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBreadcrumbAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBasicCommissioningInfoAttribute( - minInterval: Int, - maxInterval: Int - ): BasicCommissioningInfoAttribute { - // Implementation needs to be added here - } - - suspend fun readRegulatoryConfigAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeRegulatoryConfigAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLocationCapabilityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLocationCapabilityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSupportsConcurrentConnectionAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeSupportsConcurrentConnectionAttribute( - minInterval: Int, - maxInterval: Int - ): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 48u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralDiagnosticsCluster.kt deleted file mode 100644 index 543a9bcb638158..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralDiagnosticsCluster.kt +++ /dev/null @@ -1,216 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class GeneralDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class TimeSnapshotResponse(val systemTimeUs: ULong, val UTCTimeUs: ULong?) - - class NetworkInterfacesAttribute(val value: List) - - class ActiveHardwareFaultsAttribute(val value: List?) - - class ActiveRadioFaultsAttribute(val value: List?) - - class ActiveNetworkFaultsAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun testEventTrigger( - enableKey: ByteArray, - eventTrigger: ULong, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun timeSnapshot(timedInvokeTimeoutMs: Int? = null): TimeSnapshotResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNetworkInterfacesAttribute( - minInterval: Int, - maxInterval: Int - ): NetworkInterfacesAttribute { - // Implementation needs to be added here - } - - suspend fun readRebootCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRebootCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readUpTimeAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeUpTimeAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readTotalOperationalHoursAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTotalOperationalHoursAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readBootReasonAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBootReasonAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveHardwareFaultsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveHardwareFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveRadioFaultsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveRadioFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveNetworkFaultsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveNetworkFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun readTestEventTriggersEnabledAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeTestEventTriggersEnabledAttribute( - minInterval: Int, - maxInterval: Int - ): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 51u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupKeyManagementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupKeyManagementCluster.kt deleted file mode 100644 index 254d6a4bf63803..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupKeyManagementCluster.kt +++ /dev/null @@ -1,212 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class GroupKeyManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class KeySetReadResponse(val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct) - - class KeySetReadAllIndicesResponse(val groupKeySetIDs: List) - - class GroupKeyMapAttribute(val value: List) - - class GroupTableAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun keySetWrite( - groupKeySet: GroupKeyManagementClusterGroupKeySetStruct, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun keySetRead( - groupKeySetID: UShort, - timedInvokeTimeoutMs: Int? = null - ): KeySetReadResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun keySetRemove(groupKeySetID: UShort, timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun keySetReadAllIndices( - timedInvokeTimeoutMs: Int? = null - ): KeySetReadAllIndicesResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute { - // Implementation needs to be added here - } - - suspend fun readGroupKeyMapAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): GroupKeyMapAttribute { - // Implementation needs to be added here - } - - suspend fun writeGroupKeyMapAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeGroupKeyMapAttribute( - minInterval: Int, - maxInterval: Int - ): GroupKeyMapAttribute { - // Implementation needs to be added here - } - - suspend fun readGroupTableAttribute(): GroupTableAttribute { - // Implementation needs to be added here - } - - suspend fun readGroupTableAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): GroupTableAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGroupTableAttribute( - minInterval: Int, - maxInterval: Int - ): GroupTableAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxGroupsPerFabricAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeMaxGroupsPerFabricAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readMaxGroupKeysPerFabricAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeMaxGroupKeysPerFabricAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 63u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupsCluster.kt deleted file mode 100644 index 4858d7a68b38db..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupsCluster.kt +++ /dev/null @@ -1,179 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class GroupsCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddGroupResponse(val status: UInt, val groupID: UShort) - - class ViewGroupResponse(val status: UInt, val groupID: UShort, val groupName: String) - - class GetGroupMembershipResponse(val capacity: UByte?, val groupList: List) - - class RemoveGroupResponse(val status: UInt, val groupID: UShort) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun addGroup( - groupID: UShort, - groupName: String, - timedInvokeTimeoutMs: Int? = null - ): AddGroupResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun viewGroup(groupID: UShort, timedInvokeTimeoutMs: Int? = null): ViewGroupResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getGroupMembership( - groupList: List, - timedInvokeTimeoutMs: Int? = null - ): GetGroupMembershipResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeGroup(groupID: UShort, timedInvokeTimeoutMs: Int? = null): RemoveGroupResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeAllGroups(timedInvokeTimeoutMs: Int? = null) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addGroupIfIdentifying( - groupID: UShort, - groupName: String, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readNameSupportAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNameSupportAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 4u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/HepaFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/HepaFilterMonitoringCluster.kt deleted file mode 100644 index 465dd38a9397a5..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/HepaFilterMonitoringCluster.kt +++ /dev/null @@ -1,173 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class HepaFilterMonitoringCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LastChangedTimeAttribute(val value: UInt?) - - class ReplacementProductListAttribute( - val value: List? - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun resetCondition(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readConditionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeConditionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDegradationDirectionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeDegradationDirectionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readChangeIndicationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeChangeIndicationAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readInPlaceIndicatorAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeInPlaceIndicatorAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { - // Implementation needs to be added here - } - - suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLastChangedTimeAttribute( - minInterval: Int, - maxInterval: Int - ): LastChangedTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeReplacementProductListAttribute( - minInterval: Int, - maxInterval: Int - ): ReplacementProductListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 113u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IcdManagementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IcdManagementCluster.kt deleted file mode 100644 index c70094f9e08ec9..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IcdManagementCluster.kt +++ /dev/null @@ -1,225 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class IcdManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class RegisterClientResponse(val ICDCounter: UInt) - - class StayActiveResponse(val promisedActiveDuration: UInt) - - class RegisteredClientsAttribute( - val value: List? - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun registerClient( - checkInNodeID: ULong, - monitoredSubject: ULong, - key: ByteArray, - verificationKey: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): RegisterClientResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun unregisterClient( - checkInNodeID: ULong, - verificationKey: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stayActiveRequest(timedInvokeTimeoutMs: Int? = null): StayActiveResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readIdleModeDurationAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeIdleModeDurationAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readActiveModeDurationAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeActiveModeDurationAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readActiveModeThresholdAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeActiveModeThresholdAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute { - // Implementation needs to be added here - } - - suspend fun readRegisteredClientsAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): RegisteredClientsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeRegisteredClientsAttribute( - minInterval: Int, - maxInterval: Int - ): RegisteredClientsAttribute { - // Implementation needs to be added here - } - - suspend fun readICDCounterAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeICDCounterAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClientsSupportedPerFabricAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClientsSupportedPerFabricAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readUserActiveModeTriggerHintAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeUserActiveModeTriggerHintAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUserActiveModeTriggerInstructionAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeUserActiveModeTriggerInstructionAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 70u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IdentifyCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IdentifyCluster.kt deleted file mode 100644 index 72ec3e94ee2642..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IdentifyCluster.kt +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun identify(identifyTime: UShort, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun triggerEffect( - effectIdentifier: UInt, - effectVariant: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 64L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readIdentifyTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeIdentifyTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeIdentifyTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readIdentifyTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeIdentifyTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 3u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IlluminanceMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IlluminanceMeasurementCluster.kt deleted file mode 100644 index d1067f466fcc0f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IlluminanceMeasurementCluster.kt +++ /dev/null @@ -1,155 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class IlluminanceMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: UShort?) - - class MinMeasuredValueAttribute(val value: UShort?) - - class MaxMeasuredValueAttribute(val value: UShort?) - - class LightSensorTypeAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readToleranceAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeToleranceAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLightSensorTypeAttribute( - minInterval: Int, - maxInterval: Int - ): LightSensorTypeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1024u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/KeypadInputCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/KeypadInputCluster.kt deleted file mode 100644 index 365427acb053cc..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/KeypadInputCluster.kt +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class KeypadInputCluster(private val controller: MatterController, private val endpointId: UShort) { - class SendKeyResponse(val status: UInt) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun sendKey(keyCode: UInt, timedInvokeTimeoutMs: Int? = null): SendKeyResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1289u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryDryerControlsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryDryerControlsCluster.kt deleted file mode 100644 index 7b05c8dc8a4b6c..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryDryerControlsCluster.kt +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class LaundryDryerControlsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedDrynessLevelsAttribute(val value: List) - - class SelectedDrynessLevelAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedDrynessLevelsAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedDrynessLevelsAttribute { - // Implementation needs to be added here - } - - suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { - // Implementation needs to be added here - } - - suspend fun writeSelectedDrynessLevelAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSelectedDrynessLevelAttribute( - minInterval: Int, - maxInterval: Int - ): SelectedDrynessLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 74u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherControlsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherControlsCluster.kt deleted file mode 100644 index e7d246777e25c2..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherControlsCluster.kt +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class LaundryWasherControlsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SpinSpeedsAttribute(val value: List?) - - class SpinSpeedCurrentAttribute(val value: UByte?) - - class SupportedRinsesAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSpinSpeedsAttribute( - minInterval: Int, - maxInterval: Int - ): SpinSpeedsAttribute { - // Implementation needs to be added here - } - - suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute { - // Implementation needs to be added here - } - - suspend fun writeSpinSpeedCurrentAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSpinSpeedCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): SpinSpeedCurrentAttribute { - // Implementation needs to be added here - } - - suspend fun readNumberOfRinsesAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeNumberOfRinsesAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNumberOfRinsesAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedRinsesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedRinsesAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 83u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherModeCluster.kt deleted file mode 100644 index 1145e4b1d8b056..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherModeCluster.kt +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class LaundryWasherModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UInt, val statusText: String?) - - class SupportedModesAttribute(val value: List) - - class StartUpModeAttribute(val value: UByte?) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeoutMs: Int? = null - ): ChangeToModeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpModeAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 81u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LevelControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LevelControlCluster.kt deleted file mode 100644 index a20be7c6f73199..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LevelControlCluster.kt +++ /dev/null @@ -1,422 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class LevelControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class CurrentLevelAttribute(val value: UByte?) - - class OnLevelAttribute(val value: UByte?) - - class OnTransitionTimeAttribute(val value: UShort?) - - class OffTransitionTimeAttribute(val value: UShort?) - - class DefaultMoveRateAttribute(val value: UByte?) - - class StartUpCurrentLevelAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun moveToLevel( - level: UByte, - transitionTime: UShort?, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun move( - moveMode: UInt, - rate: UByte?, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun step( - stepMode: UInt, - stepSize: UByte, - transitionTime: UShort?, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stop(optionsMask: UInt, optionsOverride: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveToLevelWithOnOff( - level: UByte, - transitionTime: UShort?, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveWithOnOff( - moveMode: UInt, - rate: UByte?, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stepWithOnOff( - stepMode: UInt, - stepSize: UByte, - transitionTime: UShort?, - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stopWithOnOff( - optionsMask: UInt, - optionsOverride: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun moveToClosestFrequency(frequency: UShort, timedInvokeTimeoutMs: Int? = null) { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentLevelAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readRemainingTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRemainingTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readMinLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMinLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMaxLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMaxLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentFrequencyAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentFrequencyAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readMinFrequencyAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeMinFrequencyAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readMaxFrequencyAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeMaxFrequencyAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readOptionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeOptionsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOptionsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOnOffTransitionTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeOnOffTransitionTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnOffTransitionTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readOnLevelAttribute(): OnLevelAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnLevelAttribute(minInterval: Int, maxInterval: Int): OnLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnTransitionTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnTransitionTimeAttribute( - minInterval: Int, - maxInterval: Int - ): OnTransitionTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOffTransitionTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOffTransitionTimeAttribute( - minInterval: Int, - maxInterval: Int - ): OffTransitionTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute { - // Implementation needs to be added here - } - - suspend fun writeDefaultMoveRateAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDefaultMoveRateAttribute( - minInterval: Int, - maxInterval: Int - ): DefaultMoveRateAttribute { - // Implementation needs to be added here - } - - suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpCurrentLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpCurrentLevelAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpCurrentLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 8u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LocalizationConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LocalizationConfigurationCluster.kt deleted file mode 100644 index 4cd978399d01d7..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LocalizationConfigurationCluster.kt +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class LocalizationConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedLocalesAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readActiveLocaleAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeActiveLocaleAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeActiveLocaleAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedLocalesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedLocalesAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 43u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LowPowerCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LowPowerCluster.kt deleted file mode 100644 index 74390f3a6fb4dd..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LowPowerCluster.kt +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun sleep(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1288u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaInputCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaInputCluster.kt deleted file mode 100644 index 97ba8c68b95619..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaInputCluster.kt +++ /dev/null @@ -1,150 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) { - class InputListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun selectInput(index: UByte, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun showInputStatus(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun hideInputStatus(timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun renameInput(index: UByte, name: String, timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readInputListAttribute(): InputListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeInputListAttribute(minInterval: Int, maxInterval: Int): InputListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentInputAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentInputAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1287u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaPlaybackCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaPlaybackCluster.kt deleted file mode 100644 index 486e87eff60d06..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaPlaybackCluster.kt +++ /dev/null @@ -1,380 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class MediaPlaybackCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class PlaybackResponse(val status: UInt, val data: String?) - - class StartTimeAttribute(val value: ULong?) - - class DurationAttribute(val value: ULong?) - - class SampledPositionAttribute(val value: MediaPlaybackClusterPlaybackPositionStruct?) - - class SeekRangeEndAttribute(val value: ULong?) - - class SeekRangeStartAttribute(val value: ULong?) - - class ActiveAudioTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) - - class AvailableAudioTracksAttribute(val value: List?) - - class ActiveTextTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) - - class AvailableTextTracksAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun play(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun pause(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stop(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun startOver(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun previous(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun next(timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun rewind( - audioAdvanceUnmuted: Boolean?, - timedInvokeTimeoutMs: Int? = null - ): PlaybackResponse { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun fastForward( - audioAdvanceUnmuted: Boolean?, - timedInvokeTimeoutMs: Int? = null - ): PlaybackResponse { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun skipForward( - deltaPositionMilliseconds: ULong, - timedInvokeTimeoutMs: Int? = null - ): PlaybackResponse { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun skipBackward( - deltaPositionMilliseconds: ULong, - timedInvokeTimeoutMs: Int? = null - ): PlaybackResponse { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun seek(position: ULong, timedInvokeTimeoutMs: Int? = null): PlaybackResponse { - val commandId = 11L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun activateAudioTrack( - trackID: String, - audioOutputIndex: UByte, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 12L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun activateTextTrack(trackID: String, timedInvokeTimeoutMs: Int? = null) { - val commandId = 13L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun deactivateTextTrack(timedInvokeTimeoutMs: Int? = null) { - val commandId = 14L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readCurrentStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartTimeAttribute(): StartTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeStartTimeAttribute(minInterval: Int, maxInterval: Int): StartTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readDurationAttribute(): DurationAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDurationAttribute(minInterval: Int, maxInterval: Int): DurationAttribute { - // Implementation needs to be added here - } - - suspend fun readSampledPositionAttribute(): SampledPositionAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSampledPositionAttribute( - minInterval: Int, - maxInterval: Int - ): SampledPositionAttribute { - // Implementation needs to be added here - } - - suspend fun readPlaybackSpeedAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribePlaybackSpeedAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSeekRangeEndAttribute( - minInterval: Int, - maxInterval: Int - ): SeekRangeEndAttribute { - // Implementation needs to be added here - } - - suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSeekRangeStartAttribute( - minInterval: Int, - maxInterval: Int - ): SeekRangeStartAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveAudioTrackAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveAudioTrackAttribute { - // Implementation needs to be added here - } - - suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAvailableAudioTracksAttribute( - minInterval: Int, - maxInterval: Int - ): AvailableAudioTracksAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveTextTrackAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveTextTrackAttribute { - // Implementation needs to be added here - } - - suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAvailableTextTracksAttribute( - minInterval: Int, - maxInterval: Int - ): AvailableTextTracksAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1286u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenControlCluster.kt deleted file mode 100644 index d655422ace9ae5..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenControlCluster.kt +++ /dev/null @@ -1,160 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class MicrowaveOvenControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun setCookingParameters( - cookMode: UByte?, - cookTime: UInt?, - powerSetting: UByte?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addMoreTime(timeToAdd: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readCookTimeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeCookTimeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readPowerSettingAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePowerSettingAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMinPowerAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMinPowerAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMaxPowerAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMaxPowerAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readPowerStepAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePowerStepAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 95u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenModeCluster.kt deleted file mode 100644 index 1483cab29ac970..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenModeCluster.kt +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class MicrowaveOvenModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedModesAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 94u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ModeSelectCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ModeSelectCluster.kt deleted file mode 100644 index 22e63c94a66d54..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ModeSelectCluster.kt +++ /dev/null @@ -1,183 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) { - class StandardNamespaceAttribute(val value: UInt?) - - class SupportedModesAttribute(val value: List) - - class StartUpModeAttribute(val value: UByte?) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode(newMode: UByte, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readDescriptionAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeDescriptionAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeStandardNamespaceAttribute( - minInterval: Int, - maxInterval: Int - ): StandardNamespaceAttribute { - // Implementation needs to be added here - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpModeAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 80u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NetworkCommissioningCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NetworkCommissioningCluster.kt deleted file mode 100644 index 053471c8a853f7..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NetworkCommissioningCluster.kt +++ /dev/null @@ -1,342 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class NetworkCommissioningCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ScanNetworksResponse( - val networkingStatus: UInt, - val debugText: String?, - val wiFiScanResults: List?, - val threadScanResults: List? - ) - - class NetworkConfigResponse( - val networkingStatus: UInt, - val debugText: String?, - val networkIndex: UByte?, - val clientIdentity: ByteArray?, - val possessionSignature: ByteArray? - ) - - class ConnectNetworkResponse( - val networkingStatus: UInt, - val debugText: String?, - val errorValue: Int? - ) - - class QueryIdentityResponse(val identity: ByteArray, val possessionSignature: ByteArray?) - - class NetworksAttribute(val value: List) - - class LastNetworkingStatusAttribute(val value: UInt?) - - class LastNetworkIDAttribute(val value: ByteArray?) - - class LastConnectErrorValueAttribute(val value: Int?) - - class SupportedWiFiBandsAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun scanNetworks( - ssid: ByteArray?, - breadcrumb: ULong?, - timedInvokeTimeoutMs: Int? = null - ): ScanNetworksResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addOrUpdateWiFiNetwork( - ssid: ByteArray, - credentials: ByteArray, - breadcrumb: ULong?, - networkIdentity: ByteArray?, - clientIdentifier: ByteArray?, - possessionNonce: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): NetworkConfigResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addOrUpdateThreadNetwork( - operationalDataset: ByteArray, - breadcrumb: ULong?, - timedInvokeTimeoutMs: Int? = null - ): NetworkConfigResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeNetwork( - networkID: ByteArray, - breadcrumb: ULong?, - timedInvokeTimeoutMs: Int? = null - ): NetworkConfigResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun connectNetwork( - networkID: ByteArray, - breadcrumb: ULong?, - timedInvokeTimeoutMs: Int? = null - ): ConnectNetworkResponse { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun reorderNetwork( - networkID: ByteArray, - networkIndex: UByte, - breadcrumb: ULong?, - timedInvokeTimeoutMs: Int? = null - ): NetworkConfigResponse { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun queryIdentity( - keyIdentifier: ByteArray, - possessionNonce: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): QueryIdentityResponse { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readMaxNetworksAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMaxNetworksAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNetworksAttribute(): NetworksAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNetworksAttribute(minInterval: Int, maxInterval: Int): NetworksAttribute { - // Implementation needs to be added here - } - - suspend fun readScanMaxTimeSecondsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeScanMaxTimeSecondsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readConnectMaxTimeSecondsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeConnectMaxTimeSecondsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readInterfaceEnabledAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeInterfaceEnabledAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInterfaceEnabledAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLastNetworkingStatusAttribute( - minInterval: Int, - maxInterval: Int - ): LastNetworkingStatusAttribute { - // Implementation needs to be added here - } - - suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLastNetworkIDAttribute( - minInterval: Int, - maxInterval: Int - ): LastNetworkIDAttribute { - // Implementation needs to be added here - } - - suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLastConnectErrorValueAttribute( - minInterval: Int, - maxInterval: Int - ): LastConnectErrorValueAttribute { - // Implementation needs to be added here - } - - suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedWiFiBandsAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedWiFiBandsAttribute { - // Implementation needs to be added here - } - - suspend fun readSupportedThreadFeaturesAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedThreadFeaturesAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readThreadVersionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeThreadVersionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 49u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt deleted file mode 100644 index eb911e990eaf8f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class NitrogenDioxideConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1043u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OccupancySensingCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OccupancySensingCluster.kt deleted file mode 100644 index 07cb5e7d9ab25d..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OccupancySensingCluster.kt +++ /dev/null @@ -1,320 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OccupancySensingCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readOccupancyAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOccupancyAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOccupancySensorTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOccupancySensorTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOccupancySensorTypeBitmapAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOccupancySensorTypeBitmapAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writePIROccupiedToUnoccupiedDelayAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePIROccupiedToUnoccupiedDelayAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writePIRUnoccupiedToOccupiedDelayAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePIRUnoccupiedToOccupiedDelayAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writePIRUnoccupiedToOccupiedThresholdAttribute( - value: UByte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePIRUnoccupiedToOccupiedThresholdAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeUltrasonicOccupiedToUnoccupiedDelayAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUltrasonicOccupiedToUnoccupiedDelayAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeUltrasonicUnoccupiedToOccupiedDelayAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUltrasonicUnoccupiedToOccupiedDelayAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeUltrasonicUnoccupiedToOccupiedThresholdAttribute( - value: UByte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUltrasonicUnoccupiedToOccupiedThresholdAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writePhysicalContactOccupiedToUnoccupiedDelayAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePhysicalContactOccupiedToUnoccupiedDelayAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writePhysicalContactUnoccupiedToOccupiedDelayAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePhysicalContactUnoccupiedToOccupiedDelayAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writePhysicalContactUnoccupiedToOccupiedThresholdAttribute( - value: UByte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribePhysicalContactUnoccupiedToOccupiedThresholdAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1030u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffCluster.kt deleted file mode 100644 index 76a0996babd8e3..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffCluster.kt +++ /dev/null @@ -1,230 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) { - class StartUpOnOffAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun off(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun on(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun toggle(timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun offWithEffect( - effectIdentifier: UInt, - effectVariant: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 64L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun onWithRecallGlobalScene(timedInvokeTimeoutMs: Int? = null) { - val commandId = 65L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun onWithTimedOff( - onOffControl: UInt, - onTime: UShort, - offWaitTime: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 66L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readOnOffAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeOnOffAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readGlobalSceneControlAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeGlobalSceneControlAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readOnTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeOnTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readOffWaitTimeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeOffWaitTimeAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOffWaitTimeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpOnOffAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpOnOffAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpOnOffAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 6u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffSwitchConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffSwitchConfigurationCluster.kt deleted file mode 100644 index 71c1585a842d8d..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffSwitchConfigurationCluster.kt +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OnOffSwitchConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readSwitchTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSwitchTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSwitchActionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeSwitchActionsAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSwitchActionsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 7u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalCredentialsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalCredentialsCluster.kt deleted file mode 100644 index 66f2b93d0351d1..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalCredentialsCluster.kt +++ /dev/null @@ -1,275 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OperationalCredentialsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AttestationResponse( - val attestationElements: ByteArray, - val attestationSignature: ByteArray - ) - - class CertificateChainResponse(val certificate: ByteArray) - - class CSRResponse(val NOCSRElements: ByteArray, val attestationSignature: ByteArray) - - class NOCResponse(val statusCode: UInt, val fabricIndex: UByte?, val debugText: String?) - - class NOCsAttribute(val value: List) - - class FabricsAttribute(val value: List) - - class TrustedRootCertificatesAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun attestationRequest( - attestationNonce: ByteArray, - timedInvokeTimeoutMs: Int? = null - ): AttestationResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun certificateChainRequest( - certificateType: UInt, - timedInvokeTimeoutMs: Int? = null - ): CertificateChainResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun CSRRequest( - CSRNonce: ByteArray, - isForUpdateNOC: Boolean?, - timedInvokeTimeoutMs: Int? = null - ): CSRResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addNOC( - NOCValue: ByteArray, - ICACValue: ByteArray?, - IPKValue: ByteArray, - caseAdminSubject: ULong, - adminVendorId: UShort, - timedInvokeTimeoutMs: Int? = null - ): NOCResponse { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun updateNOC( - NOCValue: ByteArray, - ICACValue: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): NOCResponse { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun updateFabricLabel(label: String, timedInvokeTimeoutMs: Int? = null): NOCResponse { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeFabric(fabricIndex: UByte, timedInvokeTimeoutMs: Int? = null): NOCResponse { - val commandId = 10L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addTrustedRootCertificate( - rootCACertificate: ByteArray, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 11L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readNOCsAttribute(): NOCsAttribute { - // Implementation needs to be added here - } - - suspend fun readNOCsAttributeWithFabricFilter(isFabricFiltered: Boolean): NOCsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNOCsAttribute(minInterval: Int, maxInterval: Int): NOCsAttribute { - // Implementation needs to be added here - } - - suspend fun readFabricsAttribute(): FabricsAttribute { - // Implementation needs to be added here - } - - suspend fun readFabricsAttributeWithFabricFilter(isFabricFiltered: Boolean): FabricsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeFabricsAttribute(minInterval: Int, maxInterval: Int): FabricsAttribute { - // Implementation needs to be added here - } - - suspend fun readSupportedFabricsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedFabricsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCommissionedFabricsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCommissionedFabricsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTrustedRootCertificatesAttribute( - minInterval: Int, - maxInterval: Int - ): TrustedRootCertificatesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentFabricIndexAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentFabricIndexAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 62u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalStateCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalStateCluster.kt deleted file mode 100644 index 2b4222c80d4efd..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalStateCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OperationalStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class OperationalCommandResponse( - val commandResponseState: OperationalStateClusterErrorStateStruct - ) - - class PhaseListAttribute(val value: List?) - - class CurrentPhaseAttribute(val value: UByte?) - - class CountdownTimeAttribute(val value: UInt?) - - class OperationalStateListAttribute( - val value: List - ) - - class OperationalErrorAttribute(val value: OperationalStateClusterErrorStateStruct) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun pause(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stop(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun start(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resume(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readPhaseListAttribute(): PhaseListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePhaseListAttribute(minInterval: Int, maxInterval: Int): PhaseListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPhaseAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPhaseAttribute { - // Implementation needs to be added here - } - - suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCountdownTimeAttribute( - minInterval: Int, - maxInterval: Int - ): CountdownTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStateListAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalStateListAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalErrorAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalErrorAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 96u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt deleted file mode 100644 index df9a021ffe3d35..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OtaSoftwareUpdateProviderCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class QueryImageResponse( - val status: UInt, - val delayedActionTime: UInt?, - val imageURI: String?, - val softwareVersion: UInt?, - val softwareVersionString: String?, - val updateToken: ByteArray?, - val userConsentNeeded: Boolean?, - val metadataForRequestor: ByteArray? - ) - - class ApplyUpdateResponse(val action: UInt, val delayedActionTime: UInt) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun queryImage( - vendorID: UShort, - productID: UShort, - softwareVersion: UInt, - protocolsSupported: List, - hardwareVersion: UShort?, - location: String?, - requestorCanConsent: Boolean?, - metadataForProvider: ByteArray?, - timedInvokeTimeoutMs: Int? = null - ): QueryImageResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun applyUpdateRequest( - updateToken: ByteArray, - newVersion: UInt, - timedInvokeTimeoutMs: Int? = null - ): ApplyUpdateResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun notifyUpdateApplied( - updateToken: ByteArray, - softwareVersion: UInt, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 41u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt deleted file mode 100644 index 7e422996631bdb..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt +++ /dev/null @@ -1,173 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OtaSoftwareUpdateRequestorCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class DefaultOTAProvidersAttribute( - val value: List - ) - - class UpdateStateProgressAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun announceOTAProvider( - providerNodeID: ULong, - vendorID: UShort, - announcementReason: UInt, - metadataForNode: ByteArray?, - endpoint: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute { - // Implementation needs to be added here - } - - suspend fun readDefaultOTAProvidersAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): DefaultOTAProvidersAttribute { - // Implementation needs to be added here - } - - suspend fun writeDefaultOTAProvidersAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeDefaultOTAProvidersAttribute( - minInterval: Int, - maxInterval: Int - ): DefaultOTAProvidersAttribute { - // Implementation needs to be added here - } - - suspend fun readUpdatePossibleAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeUpdatePossibleAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readUpdateStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeUpdateStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeUpdateStateProgressAttribute( - minInterval: Int, - maxInterval: Int - ): UpdateStateProgressAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 42u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenCavityOperationalStateCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenCavityOperationalStateCluster.kt deleted file mode 100644 index c114fc72d1c586..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenCavityOperationalStateCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OvenCavityOperationalStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class OperationalCommandResponse( - val commandResponseState: OvenCavityOperationalStateClusterErrorStateStruct - ) - - class PhaseListAttribute(val value: List?) - - class CurrentPhaseAttribute(val value: UByte?) - - class CountdownTimeAttribute(val value: UInt?) - - class OperationalStateListAttribute( - val value: List - ) - - class OperationalErrorAttribute(val value: OvenCavityOperationalStateClusterErrorStateStruct) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun pause(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stop(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun start(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resume(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readPhaseListAttribute(): PhaseListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePhaseListAttribute(minInterval: Int, maxInterval: Int): PhaseListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPhaseAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPhaseAttribute { - // Implementation needs to be added here - } - - suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCountdownTimeAttribute( - minInterval: Int, - maxInterval: Int - ): CountdownTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStateListAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalStateListAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalErrorAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalErrorAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 72u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenModeCluster.kt deleted file mode 100644 index 267bd10448cca1..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenModeCluster.kt +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OvenModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse(val status: UInt, val statusText: String?) - - class SupportedModesAttribute(val value: List) - - class StartUpModeAttribute(val value: UByte?) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeoutMs: Int? = null - ): ChangeToModeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpModeAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 73u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt deleted file mode 100644 index 3542a8e090a8fb..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class OzoneConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1045u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt deleted file mode 100644 index f6cdf804a7642f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class Pm10ConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1069u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt deleted file mode 100644 index f07c97fbfd4468..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class Pm1ConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1068u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt deleted file mode 100644 index 424658e2bd6e0b..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class Pm25ConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1066u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceCluster.kt deleted file mode 100644 index 6dc18689f87f2d..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceCluster.kt +++ /dev/null @@ -1,414 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) { - class WiredAssessedInputVoltageAttribute(val value: UInt?) - - class WiredAssessedInputFrequencyAttribute(val value: UShort?) - - class WiredAssessedCurrentAttribute(val value: UInt?) - - class ActiveWiredFaultsAttribute(val value: List?) - - class BatVoltageAttribute(val value: UInt?) - - class BatPercentRemainingAttribute(val value: UByte?) - - class BatTimeRemainingAttribute(val value: UInt?) - - class ActiveBatFaultsAttribute(val value: List?) - - class BatTimeToFullChargeAttribute(val value: UInt?) - - class BatChargingCurrentAttribute(val value: UInt?) - - class ActiveBatChargeFaultsAttribute(val value: List?) - - class EndpointListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readStatusAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeStatusAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOrderAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOrderAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDescriptionAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeDescriptionAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeWiredAssessedInputVoltageAttribute( - minInterval: Int, - maxInterval: Int - ): WiredAssessedInputVoltageAttribute { - // Implementation needs to be added here - } - - suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeWiredAssessedInputFrequencyAttribute( - minInterval: Int, - maxInterval: Int - ): WiredAssessedInputFrequencyAttribute { - // Implementation needs to be added here - } - - suspend fun readWiredCurrentTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeWiredCurrentTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeWiredAssessedCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): WiredAssessedCurrentAttribute { - // Implementation needs to be added here - } - - suspend fun readWiredNominalVoltageAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeWiredNominalVoltageAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readWiredMaximumCurrentAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeWiredMaximumCurrentAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readWiredPresentAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeWiredPresentAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveWiredFaultsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveWiredFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun readBatVoltageAttribute(): BatVoltageAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBatVoltageAttribute( - minInterval: Int, - maxInterval: Int - ): BatVoltageAttribute { - // Implementation needs to be added here - } - - suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBatPercentRemainingAttribute( - minInterval: Int, - maxInterval: Int - ): BatPercentRemainingAttribute { - // Implementation needs to be added here - } - - suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBatTimeRemainingAttribute( - minInterval: Int, - maxInterval: Int - ): BatTimeRemainingAttribute { - // Implementation needs to be added here - } - - suspend fun readBatChargeLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBatChargeLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBatReplacementNeededAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeBatReplacementNeededAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readBatReplaceabilityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBatReplaceabilityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBatPresentAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeBatPresentAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveBatFaultsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveBatFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun readBatReplacementDescriptionAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeBatReplacementDescriptionAttribute( - minInterval: Int, - maxInterval: Int - ): CharString { - // Implementation needs to be added here - } - - suspend fun readBatCommonDesignationAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeBatCommonDesignationAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBatANSIDesignationAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeBatANSIDesignationAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readBatIECDesignationAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeBatIECDesignationAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readBatApprovedChemistryAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeBatApprovedChemistryAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBatCapacityAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeBatCapacityAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readBatQuantityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBatQuantityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBatChargeStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBatChargeStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBatTimeToFullChargeAttribute( - minInterval: Int, - maxInterval: Int - ): BatTimeToFullChargeAttribute { - // Implementation needs to be added here - } - - suspend fun readBatFunctionalWhileChargingAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeBatFunctionalWhileChargingAttribute( - minInterval: Int, - maxInterval: Int - ): Boolean { - // Implementation needs to be added here - } - - suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBatChargingCurrentAttribute( - minInterval: Int, - maxInterval: Int - ): BatChargingCurrentAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveBatChargeFaultsAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveBatChargeFaultsAttribute { - // Implementation needs to be added here - } - - suspend fun readEndpointListAttribute(): EndpointListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEndpointListAttribute( - minInterval: Int, - maxInterval: Int - ): EndpointListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 47u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceConfigurationCluster.kt deleted file mode 100644 index b90d42743b65f8..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceConfigurationCluster.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class PowerSourceConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SourcesAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readSourcesAttribute(): SourcesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSourcesAttribute(minInterval: Int, maxInterval: Int): SourcesAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 46u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PressureMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PressureMeasurementCluster.kt deleted file mode 100644 index 64c49e903d5988..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PressureMeasurementCluster.kt +++ /dev/null @@ -1,197 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class PressureMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Short?) - - class MinMeasuredValueAttribute(val value: Short?) - - class MaxMeasuredValueAttribute(val value: Short?) - - class ScaledValueAttribute(val value: Short?) - - class MinScaledValueAttribute(val value: Short?) - - class MaxScaledValueAttribute(val value: Short?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readToleranceAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeToleranceAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readScaledValueAttribute(): ScaledValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeScaledValueAttribute( - minInterval: Int, - maxInterval: Int - ): ScaledValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinScaledValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinScaledValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxScaledValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxScaledValueAttribute { - // Implementation needs to be added here - } - - suspend fun readScaledToleranceAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeScaledToleranceAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readScaleAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun subscribeScaleAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1027u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyConfigurationCluster.kt deleted file mode 100644 index fe0e582c9d45da..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyConfigurationCluster.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ProxyConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 66u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyDiscoveryCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyDiscoveryCluster.kt deleted file mode 100644 index fd1c428646a714..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyDiscoveryCluster.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ProxyDiscoveryCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 67u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyValidCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyValidCluster.kt deleted file mode 100644 index 589502096ac382..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyValidCluster.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 68u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PulseWidthModulationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PulseWidthModulationCluster.kt deleted file mode 100644 index d7e43df772c99b..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PulseWidthModulationCluster.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class PulseWidthModulationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 28u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PumpConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PumpConfigurationAndControlCluster.kt deleted file mode 100644 index 501850ac2264d9..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PumpConfigurationAndControlCluster.kt +++ /dev/null @@ -1,386 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class PumpConfigurationAndControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MaxPressureAttribute(val value: Short?) - - class MaxSpeedAttribute(val value: UShort?) - - class MaxFlowAttribute(val value: UShort?) - - class MinConstPressureAttribute(val value: Short?) - - class MaxConstPressureAttribute(val value: Short?) - - class MinCompPressureAttribute(val value: Short?) - - class MaxCompPressureAttribute(val value: Short?) - - class MinConstSpeedAttribute(val value: UShort?) - - class MaxConstSpeedAttribute(val value: UShort?) - - class MinConstFlowAttribute(val value: UShort?) - - class MaxConstFlowAttribute(val value: UShort?) - - class MinConstTempAttribute(val value: Short?) - - class MaxConstTempAttribute(val value: Short?) - - class CapacityAttribute(val value: Short?) - - class SpeedAttribute(val value: UShort?) - - class LifetimeRunningHoursAttribute(val value: UInt?) - - class PowerAttribute(val value: UInt?) - - class LifetimeEnergyConsumedAttribute(val value: UInt?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMaxPressureAttribute(): MaxPressureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxPressureAttribute( - minInterval: Int, - maxInterval: Int - ): MaxPressureAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxSpeedAttribute(minInterval: Int, maxInterval: Int): MaxSpeedAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxFlowAttribute(): MaxFlowAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxFlowAttribute(minInterval: Int, maxInterval: Int): MaxFlowAttribute { - // Implementation needs to be added here - } - - suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinConstPressureAttribute( - minInterval: Int, - maxInterval: Int - ): MinConstPressureAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxConstPressureAttribute( - minInterval: Int, - maxInterval: Int - ): MaxConstPressureAttribute { - // Implementation needs to be added here - } - - suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinCompPressureAttribute( - minInterval: Int, - maxInterval: Int - ): MinCompPressureAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxCompPressureAttribute( - minInterval: Int, - maxInterval: Int - ): MaxCompPressureAttribute { - // Implementation needs to be added here - } - - suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinConstSpeedAttribute( - minInterval: Int, - maxInterval: Int - ): MinConstSpeedAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxConstSpeedAttribute( - minInterval: Int, - maxInterval: Int - ): MaxConstSpeedAttribute { - // Implementation needs to be added here - } - - suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinConstFlowAttribute( - minInterval: Int, - maxInterval: Int - ): MinConstFlowAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxConstFlowAttribute( - minInterval: Int, - maxInterval: Int - ): MaxConstFlowAttribute { - // Implementation needs to be added here - } - - suspend fun readMinConstTempAttribute(): MinConstTempAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinConstTempAttribute( - minInterval: Int, - maxInterval: Int - ): MinConstTempAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxConstTempAttribute( - minInterval: Int, - maxInterval: Int - ): MaxConstTempAttribute { - // Implementation needs to be added here - } - - suspend fun readPumpStatusAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePumpStatusAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readEffectiveOperationModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeEffectiveOperationModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readEffectiveControlModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeEffectiveControlModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCapacityAttribute(): CapacityAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCapacityAttribute(minInterval: Int, maxInterval: Int): CapacityAttribute { - // Implementation needs to be added here - } - - suspend fun readSpeedAttribute(): SpeedAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSpeedAttribute(minInterval: Int, maxInterval: Int): SpeedAttribute { - // Implementation needs to be added here - } - - suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { - // Implementation needs to be added here - } - - suspend fun writeLifetimeRunningHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLifetimeRunningHoursAttribute( - minInterval: Int, - maxInterval: Int - ): LifetimeRunningHoursAttribute { - // Implementation needs to be added here - } - - suspend fun readPowerAttribute(): PowerAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePowerAttribute(minInterval: Int, maxInterval: Int): PowerAttribute { - // Implementation needs to be added here - } - - suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute { - // Implementation needs to be added here - } - - suspend fun writeLifetimeEnergyConsumedAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLifetimeEnergyConsumedAttribute( - minInterval: Int, - maxInterval: Int - ): LifetimeEnergyConsumedAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeOperationModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOperationModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readControlModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeControlModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeControlModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 512u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RadonConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RadonConcentrationMeasurementCluster.kt deleted file mode 100644 index 5c54c5f5fee2fe..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RadonConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RadonConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1071u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAlarmCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAlarmCluster.kt deleted file mode 100644 index 9aebd7443d205e..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAlarmCluster.kt +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RefrigeratorAlarmCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMaskAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeMaskAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readStateAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeStateAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readSupportedAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 87u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt deleted file mode 100644 index bfb589a815d089..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt +++ /dev/null @@ -1,172 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RefrigeratorAndTemperatureControlledCabinetModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UInt, val statusText: String?) - - class SupportedModesAttribute( - val value: List - ) - - class StartUpModeAttribute(val value: UByte?) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeoutMs: Int? = null - ): ChangeToModeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpModeAttribute( - minInterval: Int, - maxInterval: Int - ): StartUpModeAttribute { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 82u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RelativeHumidityMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RelativeHumidityMeasurementCluster.kt deleted file mode 100644 index d2240d51f6ae74..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RelativeHumidityMeasurementCluster.kt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RelativeHumidityMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: UShort?) - - class MinMeasuredValueAttribute(val value: UShort?) - - class MaxMeasuredValueAttribute(val value: UShort?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readToleranceAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeToleranceAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1029u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcCleanModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcCleanModeCluster.kt deleted file mode 100644 index 2a5620f647505c..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcCleanModeCluster.kt +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RvcCleanModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UInt, val statusText: String?) - - class SupportedModesAttribute(val value: List) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeoutMs: Int? = null - ): ChangeToModeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 85u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcOperationalStateCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcOperationalStateCluster.kt deleted file mode 100644 index abb27510e5590c..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcOperationalStateCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RvcOperationalStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class OperationalCommandResponse( - val commandResponseState: RvcOperationalStateClusterErrorStateStruct - ) - - class PhaseListAttribute(val value: List?) - - class CurrentPhaseAttribute(val value: UByte?) - - class CountdownTimeAttribute(val value: UInt?) - - class OperationalStateListAttribute( - val value: List - ) - - class OperationalErrorAttribute(val value: RvcOperationalStateClusterErrorStateStruct) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun pause(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stop(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun start(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resume(timedInvokeTimeoutMs: Int? = null): OperationalCommandResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readPhaseListAttribute(): PhaseListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePhaseListAttribute(minInterval: Int, maxInterval: Int): PhaseListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPhaseAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPhaseAttribute { - // Implementation needs to be added here - } - - suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCountdownTimeAttribute( - minInterval: Int, - maxInterval: Int - ): CountdownTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStateListAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalStateListAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalErrorAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalErrorAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 97u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcRunModeCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcRunModeCluster.kt deleted file mode 100644 index 6c4879b6144e03..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcRunModeCluster.kt +++ /dev/null @@ -1,146 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class RvcRunModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse(val status: UInt, val statusText: String?) - - class SupportedModesAttribute(val value: List) - - class OnModeAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeoutMs: Int? = null - ): ChangeToModeResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedModesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedModesAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readOnModeAttribute(): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOnModeAttribute(minInterval: Int, maxInterval: Int): OnModeAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 84u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SampleMeiCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SampleMeiCluster.kt deleted file mode 100644 index a19737df6c3d4e..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SampleMeiCluster.kt +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class SampleMeiCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddArgumentsResponse(val returnValue: UByte) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun ping(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addArguments( - arg1: UByte, - arg2: UByte, - timedInvokeTimeoutMs: Int? = null - ): AddArgumentsResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readFlipFlopAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeFlipFlopAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeFlipFlopAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 4294048800u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ScenesCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ScenesCluster.kt deleted file mode 100644 index 0a19851046e346..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ScenesCluster.kt +++ /dev/null @@ -1,361 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ScenesCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) - - class ViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UShort?, - val sceneName: String?, - val extensionFieldSets: List? - ) - - class RemoveSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) - - class RemoveAllScenesResponse(val status: UByte, val groupID: UShort) - - class StoreSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) - - class GetSceneMembershipResponse( - val status: UByte, - val capacity: UByte?, - val groupID: UShort, - val sceneList: List? - ) - - class EnhancedAddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) - - class EnhancedViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UShort?, - val sceneName: String?, - val extensionFieldSets: List? - ) - - class CopySceneResponse( - val status: UByte, - val groupIdentifierFrom: UShort, - val sceneIdentifierFrom: UByte - ) - - class LastConfiguredByAttribute(val value: ULong?) - - class FabricSceneInfoAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun addScene( - groupID: UShort, - sceneID: UByte, - transitionTime: UShort, - sceneName: String, - extensionFieldSets: List, - timedInvokeTimeoutMs: Int? = null - ): AddSceneResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun viewScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeoutMs: Int? = null - ): ViewSceneResponse { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeoutMs: Int? = null - ): RemoveSceneResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun removeAllScenes( - groupID: UShort, - timedInvokeTimeoutMs: Int? = null - ): RemoveAllScenesResponse { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun storeScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeoutMs: Int? = null - ): StoreSceneResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun recallScene( - groupID: UShort, - sceneID: UByte, - transitionTime: UShort?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getSceneMembership( - groupID: UShort, - timedInvokeTimeoutMs: Int? = null - ): GetSceneMembershipResponse { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enhancedAddScene( - groupID: UShort, - sceneID: UByte, - transitionTime: UShort, - sceneName: String, - extensionFieldSets: List, - timedInvokeTimeoutMs: Int? = null - ): EnhancedAddSceneResponse { - val commandId = 64L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun enhancedViewScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeoutMs: Int? = null - ): EnhancedViewSceneResponse { - val commandId = 65L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun copyScene( - mode: UInt, - groupIdentifierFrom: UShort, - sceneIdentifierFrom: UByte, - groupIdentifierTo: UShort, - sceneIdentifierTo: UByte, - timedInvokeTimeoutMs: Int? = null - ): CopySceneResponse { - val commandId = 66L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSceneCountAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSceneCountAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentSceneAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentSceneAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentGroupAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentGroupAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readSceneValidAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeSceneValidAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readNameSupportAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNameSupportAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLastConfiguredByAttribute( - minInterval: Int, - maxInterval: Int - ): LastConfiguredByAttribute { - // Implementation needs to be added here - } - - suspend fun readSceneTableSizeAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeSceneTableSizeAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute { - // Implementation needs to be added here - } - - suspend fun readFabricSceneInfoAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): FabricSceneInfoAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeFabricSceneInfoAttribute( - minInterval: Int, - maxInterval: Int - ): FabricSceneInfoAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 5u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SmokeCoAlarmCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SmokeCoAlarmCluster.kt deleted file mode 100644 index 384b52fbfcfea7..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SmokeCoAlarmCluster.kt +++ /dev/null @@ -1,217 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class SmokeCoAlarmCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun selfTestRequest(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readExpressedStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeExpressedStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSmokeStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSmokeStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCOStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCOStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBatteryAlertAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeBatteryAlertAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDeviceMutedAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeDeviceMutedAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readTestInProgressAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeTestInProgressAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readHardwareFaultAlertAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeHardwareFaultAlertAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readEndOfServiceAlertAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeEndOfServiceAlertAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readInterconnectSmokeAlarmAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeInterconnectSmokeAlarmAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readInterconnectCOAlarmAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeInterconnectCOAlarmAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readContaminationStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeContaminationStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSmokeSensitivityLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeSmokeSensitivityLevelAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSmokeSensitivityLevelAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readExpiryDateAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeExpiryDateAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 92u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SoftwareDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SoftwareDiagnosticsCluster.kt deleted file mode 100644 index 0132daa4368246..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SoftwareDiagnosticsCluster.kt +++ /dev/null @@ -1,145 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class SoftwareDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ThreadMetricsAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun resetWatermarks(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeThreadMetricsAttribute( - minInterval: Int, - maxInterval: Int - ): ThreadMetricsAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentHeapFreeAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentHeapFreeAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readCurrentHeapUsedAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentHeapUsedAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readCurrentHeapHighWatermarkAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentHeapHighWatermarkAttribute( - minInterval: Int, - maxInterval: Int - ): ULong { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 52u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SwitchCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SwitchCluster.kt deleted file mode 100644 index a27cc29bd7b640..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SwitchCluster.kt +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readNumberOfPositionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfPositionsAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMultiPressMaxAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMultiPressMaxAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 59u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TargetNavigatorCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TargetNavigatorCluster.kt deleted file mode 100644 index 691bc7adc452b1..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TargetNavigatorCluster.kt +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TargetNavigatorCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class NavigateTargetResponse(val status: UInt, val data: String?) - - class TargetListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun navigateTarget( - target: UByte, - data: String?, - timedInvokeTimeoutMs: Int? = null - ): NavigateTargetResponse { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readTargetListAttribute(): TargetListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTargetListAttribute( - minInterval: Int, - maxInterval: Int - ): TargetListAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentTargetAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentTargetAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1285u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureControlCluster.kt deleted file mode 100644 index 978f543f84231a..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureControlCluster.kt +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TemperatureControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedTemperatureLevelsAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun setTemperature( - targetTemperature: Short?, - targetTemperatureLevel: UByte?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readTemperatureSetpointAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeTemperatureSetpointAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readMinTemperatureAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMinTemperatureAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readMaxTemperatureAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeMaxTemperatureAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readStepAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeStepAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readSelectedTemperatureLevelAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSelectedTemperatureLevelAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedTemperatureLevelsAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedTemperatureLevelsAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 86u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureMeasurementCluster.kt deleted file mode 100644 index 5c6a6ff41fd1eb..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureMeasurementCluster.kt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TemperatureMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Short?) - - class MinMeasuredValueAttribute(val value: Short?) - - class MaxMeasuredValueAttribute(val value: Short?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readToleranceAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeToleranceAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1026u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatCluster.kt deleted file mode 100644 index 6eeddc77e8fb7f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatCluster.kt +++ /dev/null @@ -1,867 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ThermostatCluster(private val controller: MatterController, private val endpointId: UShort) { - class GetWeeklyScheduleResponse( - val numberOfTransitionsForSequence: UByte, - val dayOfWeekForSequence: UInt, - val modeForSequence: UInt, - val transitions: List - ) - - class LocalTemperatureAttribute(val value: Short?) - - class OutdoorTemperatureAttribute(val value: Short?) - - class TemperatureSetpointHoldDurationAttribute(val value: UShort?) - - class SetpointChangeAmountAttribute(val value: Short?) - - class OccupiedSetbackAttribute(val value: UByte?) - - class OccupiedSetbackMinAttribute(val value: UByte?) - - class OccupiedSetbackMaxAttribute(val value: UByte?) - - class UnoccupiedSetbackAttribute(val value: UByte?) - - class UnoccupiedSetbackMinAttribute(val value: UByte?) - - class UnoccupiedSetbackMaxAttribute(val value: UByte?) - - class ACCoilTemperatureAttribute(val value: Short?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun setpointRaiseLower(mode: UInt, amount: Byte, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setWeeklySchedule( - numberOfTransitionsForSequence: UByte, - dayOfWeekForSequence: UInt, - modeForSequence: UInt, - transitions: List, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun getWeeklySchedule( - daysToReturn: UInt, - modeToReturn: UInt, - timedInvokeTimeoutMs: Int? = null - ): GetWeeklyScheduleResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun clearWeeklySchedule(timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLocalTemperatureAttribute( - minInterval: Int, - maxInterval: Int - ): LocalTemperatureAttribute { - // Implementation needs to be added here - } - - suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOutdoorTemperatureAttribute( - minInterval: Int, - maxInterval: Int - ): OutdoorTemperatureAttribute { - // Implementation needs to be added here - } - - suspend fun readOccupancyAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOccupancyAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readAbsMinHeatSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAbsMinHeatSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAbsMaxHeatSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAbsMinCoolSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAbsMinCoolSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun subscribeAbsMaxCoolSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readPICoolingDemandAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePICoolingDemandAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readPIHeatingDemandAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribePIHeatingDemandAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readHVACSystemTypeConfigurationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeHVACSystemTypeConfigurationAttribute( - value: UInt, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeHVACSystemTypeConfigurationAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readLocalTemperatureCalibrationAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun writeLocalTemperatureCalibrationAttribute( - value: Byte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLocalTemperatureCalibrationAttribute( - minInterval: Int, - maxInterval: Int - ): Byte { - // Implementation needs to be added here - } - - suspend fun readOccupiedCoolingSetpointAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeOccupiedCoolingSetpointAttribute( - value: Short, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOccupiedCoolingSetpointAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readOccupiedHeatingSetpointAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeOccupiedHeatingSetpointAttribute( - value: Short, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOccupiedHeatingSetpointAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readUnoccupiedCoolingSetpointAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeUnoccupiedCoolingSetpointAttribute( - value: Short, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUnoccupiedCoolingSetpointAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readUnoccupiedHeatingSetpointAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeUnoccupiedHeatingSetpointAttribute( - value: Short, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUnoccupiedHeatingSetpointAttribute( - minInterval: Int, - maxInterval: Int - ): Short { - // Implementation needs to be added here - } - - suspend fun readMinHeatSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeMinHeatSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMinHeatSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readMaxHeatSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeMaxHeatSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMaxHeatSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readMinCoolSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeMinCoolSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMinCoolSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readMaxCoolSetpointLimitAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeMaxCoolSetpointLimitAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMaxCoolSetpointLimitAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readMinSetpointDeadBandAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun writeMinSetpointDeadBandAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeMinSetpointDeadBandAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readRemoteSensingAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeRemoteSensingAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRemoteSensingAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readControlSequenceOfOperationAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeControlSequenceOfOperationAttribute( - value: UInt, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeControlSequenceOfOperationAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readSystemModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeSystemModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeSystemModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readThermostatRunningModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeThermostatRunningModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStartOfWeekAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeStartOfWeekAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfWeeklyTransitionsAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readNumberOfDailyTransitionsAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfDailyTransitionsAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readTemperatureSetpointHoldAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeTemperatureSetpointHoldAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeTemperatureSetpointHoldAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readTemperatureSetpointHoldDurationAttribute(): - TemperatureSetpointHoldDurationAttribute { - // Implementation needs to be added here - } - - suspend fun writeTemperatureSetpointHoldDurationAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeTemperatureSetpointHoldDurationAttribute( - minInterval: Int, - maxInterval: Int - ): TemperatureSetpointHoldDurationAttribute { - // Implementation needs to be added here - } - - suspend fun readThermostatProgrammingOperationModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeThermostatProgrammingOperationModeAttribute( - value: UInt, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeThermostatProgrammingOperationModeAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readThermostatRunningStateAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeThermostatRunningStateAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readSetpointChangeSourceAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeSetpointChangeSourceAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSetpointChangeAmountAttribute( - minInterval: Int, - maxInterval: Int - ): SetpointChangeAmountAttribute { - // Implementation needs to be added here - } - - suspend fun readSetpointChangeSourceTimestampAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSetpointChangeSourceTimestampAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute { - // Implementation needs to be added here - } - - suspend fun writeOccupiedSetbackAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOccupiedSetbackAttribute( - minInterval: Int, - maxInterval: Int - ): OccupiedSetbackAttribute { - // Implementation needs to be added here - } - - suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOccupiedSetbackMinAttribute( - minInterval: Int, - maxInterval: Int - ): OccupiedSetbackMinAttribute { - // Implementation needs to be added here - } - - suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOccupiedSetbackMaxAttribute( - minInterval: Int, - maxInterval: Int - ): OccupiedSetbackMaxAttribute { - // Implementation needs to be added here - } - - suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute { - // Implementation needs to be added here - } - - suspend fun writeUnoccupiedSetbackAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUnoccupiedSetbackAttribute( - minInterval: Int, - maxInterval: Int - ): UnoccupiedSetbackAttribute { - // Implementation needs to be added here - } - - suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeUnoccupiedSetbackMinAttribute( - minInterval: Int, - maxInterval: Int - ): UnoccupiedSetbackMinAttribute { - // Implementation needs to be added here - } - - suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeUnoccupiedSetbackMaxAttribute( - minInterval: Int, - maxInterval: Int - ): UnoccupiedSetbackMaxAttribute { - // Implementation needs to be added here - } - - suspend fun readEmergencyHeatDeltaAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeEmergencyHeatDeltaAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEmergencyHeatDeltaAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readACTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeACTypeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readACCapacityAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeACCapacityAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACCapacityAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readACRefrigerantTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeACRefrigerantTypeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACRefrigerantTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readACCompressorTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeACCompressorTypeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACCompressorTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readACErrorCodeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeACErrorCodeAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACErrorCodeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readACLouverPositionAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeACLouverPositionAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACLouverPositionAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeACCoilTemperatureAttribute( - minInterval: Int, - maxInterval: Int - ): ACCoilTemperatureAttribute { - // Implementation needs to be added here - } - - suspend fun readACCapacityformatAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeACCapacityformatAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeACCapacityformatAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 513u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt deleted file mode 100644 index 12ed570344c446..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ThermostatUserInterfaceConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readTemperatureDisplayModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeTemperatureDisplayModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeTemperatureDisplayModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readKeypadLockoutAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeKeypadLockoutAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeKeypadLockoutAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readScheduleProgrammingVisibilityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeScheduleProgrammingVisibilityAttribute( - value: UInt, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeScheduleProgrammingVisibilityAttribute( - minInterval: Int, - maxInterval: Int - ): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 516u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt deleted file mode 100644 index 86e2cb8e290a64..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt +++ /dev/null @@ -1,711 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ThreadNetworkDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChannelAttribute(val value: UShort?) - - class RoutingRoleAttribute(val value: UInt?) - - class NetworkNameAttribute(val value: String?) - - class PanIdAttribute(val value: UShort?) - - class ExtendedPanIdAttribute(val value: ULong?) - - class MeshLocalPrefixAttribute(val value: ByteArray?) - - class NeighborTableAttribute(val value: List) - - class RouteTableAttribute(val value: List) - - class PartitionIdAttribute(val value: UInt?) - - class WeightingAttribute(val value: UShort?) - - class DataVersionAttribute(val value: UShort?) - - class StableDataVersionAttribute(val value: UShort?) - - class LeaderRouterIdAttribute(val value: UByte?) - - class ActiveTimestampAttribute(val value: ULong?) - - class PendingTimestampAttribute(val value: ULong?) - - class DelayAttribute(val value: UInt?) - - class SecurityPolicyAttribute(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) - - class ChannelPage0MaskAttribute(val value: ByteArray?) - - class OperationalDatasetComponentsAttribute( - val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? - ) - - class ActiveNetworkFaultsListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun resetCounts(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readChannelAttribute(): ChannelAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeChannelAttribute(minInterval: Int, maxInterval: Int): ChannelAttribute { - // Implementation needs to be added here - } - - suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeRoutingRoleAttribute( - minInterval: Int, - maxInterval: Int - ): RoutingRoleAttribute { - // Implementation needs to be added here - } - - suspend fun readNetworkNameAttribute(): NetworkNameAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNetworkNameAttribute( - minInterval: Int, - maxInterval: Int - ): NetworkNameAttribute { - // Implementation needs to be added here - } - - suspend fun readPanIdAttribute(): PanIdAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePanIdAttribute(minInterval: Int, maxInterval: Int): PanIdAttribute { - // Implementation needs to be added here - } - - suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeExtendedPanIdAttribute( - minInterval: Int, - maxInterval: Int - ): ExtendedPanIdAttribute { - // Implementation needs to be added here - } - - suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeshLocalPrefixAttribute( - minInterval: Int, - maxInterval: Int - ): MeshLocalPrefixAttribute { - // Implementation needs to be added here - } - - suspend fun readOverrunCountAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun subscribeOverrunCountAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readNeighborTableAttribute(): NeighborTableAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeNeighborTableAttribute( - minInterval: Int, - maxInterval: Int - ): NeighborTableAttribute { - // Implementation needs to be added here - } - - suspend fun readRouteTableAttribute(): RouteTableAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeRouteTableAttribute( - minInterval: Int, - maxInterval: Int - ): RouteTableAttribute { - // Implementation needs to be added here - } - - suspend fun readPartitionIdAttribute(): PartitionIdAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePartitionIdAttribute( - minInterval: Int, - maxInterval: Int - ): PartitionIdAttribute { - // Implementation needs to be added here - } - - suspend fun readWeightingAttribute(): WeightingAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeWeightingAttribute(minInterval: Int, maxInterval: Int): WeightingAttribute { - // Implementation needs to be added here - } - - suspend fun readDataVersionAttribute(): DataVersionAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDataVersionAttribute( - minInterval: Int, - maxInterval: Int - ): DataVersionAttribute { - // Implementation needs to be added here - } - - suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeStableDataVersionAttribute( - minInterval: Int, - maxInterval: Int - ): StableDataVersionAttribute { - // Implementation needs to be added here - } - - suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLeaderRouterIdAttribute( - minInterval: Int, - maxInterval: Int - ): LeaderRouterIdAttribute { - // Implementation needs to be added here - } - - suspend fun readDetachedRoleCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeDetachedRoleCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readChildRoleCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeChildRoleCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRouterRoleCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeRouterRoleCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readLeaderRoleCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeLeaderRoleCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readAttachAttemptCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeAttachAttemptCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readPartitionIdChangeCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePartitionIdChangeCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeBetterPartitionAttachAttemptCountAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readParentChangeCountAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeParentChangeCountAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readTxTotalCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxTotalCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxUnicastCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxUnicastCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxBroadcastCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxBroadcastCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxAckRequestedCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxAckRequestedCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxAckedCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxAckedCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxNoAckRequestedCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxNoAckRequestedCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxDataCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxDataCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxDataPollCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxDataPollCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxBeaconCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxBeaconCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxBeaconRequestCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxBeaconRequestCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxOtherCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxOtherCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxRetryCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxRetryCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxDirectMaxRetryExpiryCountAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxIndirectMaxRetryExpiryCountAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readTxErrCcaCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxErrCcaCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxErrAbortCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxErrAbortCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTxErrBusyChannelCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTxErrBusyChannelCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxTotalCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxTotalCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxUnicastCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxUnicastCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxBroadcastCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxBroadcastCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxDataCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxDataCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxDataPollCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxDataPollCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxBeaconCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxBeaconCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxBeaconRequestCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxBeaconRequestCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxOtherCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxOtherCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxAddressFilteredCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxAddressFilteredCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxDestAddrFilteredCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxDestAddrFilteredCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxDuplicatedCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxDuplicatedCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxErrNoFrameCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxErrNoFrameCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxErrUnknownNeighborCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxErrUnknownNeighborCountAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxErrInvalidSrcAddrCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxErrSecCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxErrSecCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxErrFcsCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxErrFcsCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readRxErrOtherCountAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeRxErrOtherCountAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveTimestampAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveTimestampAttribute { - // Implementation needs to be added here - } - - suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePendingTimestampAttribute( - minInterval: Int, - maxInterval: Int - ): PendingTimestampAttribute { - // Implementation needs to be added here - } - - suspend fun readDelayAttribute(): DelayAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDelayAttribute(minInterval: Int, maxInterval: Int): DelayAttribute { - // Implementation needs to be added here - } - - suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSecurityPolicyAttribute( - minInterval: Int, - maxInterval: Int - ): SecurityPolicyAttribute { - // Implementation needs to be added here - } - - suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeChannelPage0MaskAttribute( - minInterval: Int, - maxInterval: Int - ): ChannelPage0MaskAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalDatasetComponentsAttribute( - minInterval: Int, - maxInterval: Int - ): OperationalDatasetComponentsAttribute { - // Implementation needs to be added here - } - - suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeActiveNetworkFaultsListAttribute( - minInterval: Int, - maxInterval: Int - ): ActiveNetworkFaultsListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 53u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeFormatLocalizationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeFormatLocalizationCluster.kt deleted file mode 100644 index d3916cb0db2233..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeFormatLocalizationCluster.kt +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TimeFormatLocalizationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedCalendarTypesAttribute(val value: List?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readHourFormatAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeHourFormatAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeHourFormatAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readActiveCalendarTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeActiveCalendarTypeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeActiveCalendarTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSupportedCalendarTypesAttribute( - minInterval: Int, - maxInterval: Int - ): SupportedCalendarTypesAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 44u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeSynchronizationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeSynchronizationCluster.kt deleted file mode 100644 index d9b0d983141f95..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeSynchronizationCluster.kt +++ /dev/null @@ -1,283 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TimeSynchronizationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SetTimeZoneResponse(val DSTOffsetRequired: Boolean) - - class UTCTimeAttribute(val value: ULong?) - - class TrustedTimeSourceAttribute(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) - - class DefaultNTPAttribute(val value: String?) - - class TimeZoneAttribute(val value: List?) - - class DSTOffsetAttribute(val value: List?) - - class LocalTimeAttribute(val value: ULong?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun setUTCTime( - UTCTime: ULong, - granularity: UInt, - timeSource: UInt?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setTrustedTimeSource( - trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct?, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setTimeZone( - timeZone: List, - timedInvokeTimeoutMs: Int? = null - ): SetTimeZoneResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setDSTOffset( - DSTOffset: List, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setDefaultNTP(defaultNTP: String?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readUTCTimeAttribute(): UTCTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeUTCTimeAttribute(minInterval: Int, maxInterval: Int): UTCTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readGranularityAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeGranularityAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readTimeSourceAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeTimeSourceAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTrustedTimeSourceAttribute( - minInterval: Int, - maxInterval: Int - ): TrustedTimeSourceAttribute { - // Implementation needs to be added here - } - - suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDefaultNTPAttribute( - minInterval: Int, - maxInterval: Int - ): DefaultNTPAttribute { - // Implementation needs to be added here - } - - suspend fun readTimeZoneAttribute(): TimeZoneAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTimeZoneAttribute(minInterval: Int, maxInterval: Int): TimeZoneAttribute { - // Implementation needs to be added here - } - - suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeDSTOffsetAttribute(minInterval: Int, maxInterval: Int): DSTOffsetAttribute { - // Implementation needs to be added here - } - - suspend fun readLocalTimeAttribute(): LocalTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeLocalTimeAttribute(minInterval: Int, maxInterval: Int): LocalTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readTimeZoneDatabaseAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeTimeZoneDatabaseAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readNTPServerAvailableAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeNTPServerAvailableAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readTimeZoneListMaxSizeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeTimeZoneListMaxSizeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readDSTOffsetListMaxSizeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeDSTOffsetListMaxSizeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSupportsDNSResolveAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun subscribeSupportsDNSResolveAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 56u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimerCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimerCluster.kt deleted file mode 100644 index 2ec115fde7742e..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimerCluster.kt +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TimerCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun setTimer(newTime: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun resetTimer(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun addTime(additionalTime: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun reduceTime(timeReduction: UInt, timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readSetTimeAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeSetTimeAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTimeRemainingAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeTimeRemainingAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readTimerStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeTimerStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 71u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt deleted file mode 100644 index bd37b97759d83e..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) - - class MinMeasuredValueAttribute(val value: Float?) - - class MaxMeasuredValueAttribute(val value: Float?) - - class PeakMeasuredValueAttribute(val value: Float?) - - class AverageMeasuredValueAttribute(val value: Float?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMinMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MinMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeMaxMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): MaxMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): PeakMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribePeakMeasuredValueWindowAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueAttribute( - minInterval: Int, - maxInterval: Int - ): AverageMeasuredValueAttribute { - // Implementation needs to be added here - } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeAverageMeasuredValueWindowAttribute( - minInterval: Int, - maxInterval: Int - ): UInt { - // Implementation needs to be added here - } - - suspend fun readUncertaintyAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun subscribeUncertaintyAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readMeasurementUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readMeasurementMediumAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeMeasurementMediumAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readLevelValueAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeLevelValueAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1070u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitLocalizationCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitLocalizationCluster.kt deleted file mode 100644 index 573489cd5d60bd..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitLocalizationCluster.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class UnitLocalizationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readTemperatureUnitAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeTemperatureUnitAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeTemperatureUnitAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 45u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitTestingCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitTestingCluster.kt deleted file mode 100644 index 30cfa97aab4cec..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitTestingCluster.kt +++ /dev/null @@ -1,1991 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class UnitTestingCluster(private val controller: MatterController, private val endpointId: UShort) { - class TestSpecificResponse(val returnValue: UByte) - - class TestAddArgumentsResponse(val returnValue: UByte) - - class TestSimpleArgumentResponse(val returnValue: Boolean) - - class TestStructArrayArgumentResponse( - val arg1: List, - val arg2: List, - val arg3: List, - val arg4: List, - val arg5: UInt, - val arg6: Boolean - ) - - class BooleanResponse(val value: Boolean) - - class TestListInt8UReverseResponse(val arg1: List) - - class TestEnumsResponse(val arg1: UShort, val arg2: UInt) - - class TestNullableOptionalResponse( - val wasPresent: Boolean, - val wasNull: Boolean?, - val value: UByte?, - val originalValue: UByte? - ) - - class TestComplexNullableOptionalResponse( - val nullableIntWasNull: Boolean, - val nullableIntValue: UShort?, - val optionalIntWasPresent: Boolean, - val optionalIntValue: UShort?, - val nullableOptionalIntWasPresent: Boolean, - val nullableOptionalIntWasNull: Boolean?, - val nullableOptionalIntValue: UShort?, - val nullableStringWasNull: Boolean, - val nullableStringValue: String?, - val optionalStringWasPresent: Boolean, - val optionalStringValue: String?, - val nullableOptionalStringWasPresent: Boolean, - val nullableOptionalStringWasNull: Boolean?, - val nullableOptionalStringValue: String?, - val nullableStructWasNull: Boolean, - val nullableStructValue: UnitTestingClusterSimpleStruct?, - val optionalStructWasPresent: Boolean, - val optionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableOptionalStructWasPresent: Boolean, - val nullableOptionalStructWasNull: Boolean?, - val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableListWasNull: Boolean, - val nullableListValue: List?, - val optionalListWasPresent: Boolean, - val optionalListValue: List?, - val nullableOptionalListWasPresent: Boolean, - val nullableOptionalListWasNull: Boolean?, - val nullableOptionalListValue: List? - ) - - class SimpleStructResponse(val arg1: UnitTestingClusterSimpleStruct) - - class TestEmitTestEventResponse(val value: ULong) - - class TestEmitTestFabricScopedEventResponse(val value: ULong) - - class ListInt8uAttribute(val value: List) - - class ListOctetStringAttribute(val value: List) - - class ListStructOctetStringAttribute(val value: List) - - class ListNullablesAndOptionalsStructAttribute( - val value: List - ) - - class StructAttrAttribute(val value: UnitTestingClusterSimpleStruct) - - class ListLongOctetStringAttribute(val value: List) - - class ListFabricScopedAttribute(val value: List) - - class NullableBooleanAttribute(val value: Boolean?) - - class NullableBitmap8Attribute(val value: UInt?) - - class NullableBitmap16Attribute(val value: UInt?) - - class NullableBitmap32Attribute(val value: ULong?) - - class NullableBitmap64Attribute(val value: ULong?) - - class NullableInt8uAttribute(val value: UByte?) - - class NullableInt16uAttribute(val value: UShort?) - - class NullableInt24uAttribute(val value: UInt?) - - class NullableInt32uAttribute(val value: UInt?) - - class NullableInt40uAttribute(val value: ULong?) - - class NullableInt48uAttribute(val value: ULong?) - - class NullableInt56uAttribute(val value: ULong?) - - class NullableInt64uAttribute(val value: ULong?) - - class NullableInt8sAttribute(val value: Byte?) - - class NullableInt16sAttribute(val value: Short?) - - class NullableInt24sAttribute(val value: Int?) - - class NullableInt32sAttribute(val value: Int?) - - class NullableInt40sAttribute(val value: Long?) - - class NullableInt48sAttribute(val value: Long?) - - class NullableInt56sAttribute(val value: Long?) - - class NullableInt64sAttribute(val value: Long?) - - class NullableEnum8Attribute(val value: UInt?) - - class NullableEnum16Attribute(val value: UInt?) - - class NullableFloatSingleAttribute(val value: Float?) - - class NullableFloatDoubleAttribute(val value: Double?) - - class NullableOctetStringAttribute(val value: ByteArray?) - - class NullableCharStringAttribute(val value: String?) - - class NullableEnumAttrAttribute(val value: UInt?) - - class NullableStructAttribute(val value: UnitTestingClusterSimpleStruct?) - - class NullableRangeRestrictedInt8uAttribute(val value: UByte?) - - class NullableRangeRestrictedInt8sAttribute(val value: Byte?) - - class NullableRangeRestrictedInt16uAttribute(val value: UShort?) - - class NullableRangeRestrictedInt16sAttribute(val value: Short?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun test(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testNotHandled(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testSpecific(timedInvokeTimeoutMs: Int? = null): TestSpecificResponse { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testUnknownCommand(timedInvokeTimeoutMs: Int? = null) { - val commandId = 3L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testAddArguments( - arg1: UByte, - arg2: UByte, - timedInvokeTimeoutMs: Int? = null - ): TestAddArgumentsResponse { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testSimpleArgumentRequest( - arg1: Boolean, - timedInvokeTimeoutMs: Int? = null - ): TestSimpleArgumentResponse { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testStructArrayArgumentRequest( - arg1: List, - arg2: List, - arg3: List, - arg4: List, - arg5: UInt, - arg6: Boolean, - timedInvokeTimeoutMs: Int? = null - ): TestStructArrayArgumentResponse { - val commandId = 6L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testStructArgumentRequest( - arg1: UnitTestingClusterSimpleStruct, - timedInvokeTimeoutMs: Int? = null - ): BooleanResponse { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testNestedStructArgumentRequest( - arg1: UnitTestingClusterNestedStruct, - timedInvokeTimeoutMs: Int? = null - ): BooleanResponse { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testListStructArgumentRequest( - arg1: List, - timedInvokeTimeoutMs: Int? = null - ): BooleanResponse { - val commandId = 9L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testListInt8UArgumentRequest( - arg1: List, - timedInvokeTimeoutMs: Int? = null - ): BooleanResponse { - val commandId = 10L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testNestedStructListArgumentRequest( - arg1: UnitTestingClusterNestedStructList, - timedInvokeTimeoutMs: Int? = null - ): BooleanResponse { - val commandId = 11L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testListNestedStructListArgumentRequest( - arg1: List, - timedInvokeTimeoutMs: Int? = null - ): BooleanResponse { - val commandId = 12L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testListInt8UReverseRequest( - arg1: List, - timedInvokeTimeoutMs: Int? = null - ): TestListInt8UReverseResponse { - val commandId = 13L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testEnumsRequest( - arg1: UShort, - arg2: UInt, - timedInvokeTimeoutMs: Int? = null - ): TestEnumsResponse { - val commandId = 14L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testNullableOptionalRequest( - arg1: UByte?, - timedInvokeTimeoutMs: Int? = null - ): TestNullableOptionalResponse { - val commandId = 15L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testComplexNullableOptionalRequest( - nullableInt: UShort?, - optionalInt: UShort?, - nullableOptionalInt: UShort?, - nullableString: String?, - optionalString: String?, - nullableOptionalString: String?, - nullableStruct: UnitTestingClusterSimpleStruct?, - optionalStruct: UnitTestingClusterSimpleStruct?, - nullableOptionalStruct: UnitTestingClusterSimpleStruct?, - nullableList: List?, - optionalList: List?, - nullableOptionalList: List?, - timedInvokeTimeoutMs: Int? = null - ): TestComplexNullableOptionalResponse { - val commandId = 16L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun simpleStructEchoRequest( - arg1: UnitTestingClusterSimpleStruct, - timedInvokeTimeoutMs: Int? = null - ): SimpleStructResponse { - val commandId = 17L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun timedInvokeRequest(timedInvokeTimeoutMs: Int) { - val commandId = 18L - - // Implementation needs to be added here - } - - suspend fun testSimpleOptionalArgumentRequest(arg1: Boolean?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 19L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testEmitTestEventRequest( - arg1: UByte, - arg2: UInt, - arg3: Boolean, - timedInvokeTimeoutMs: Int? = null - ): TestEmitTestEventResponse { - val commandId = 20L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun testEmitTestFabricScopedEventRequest( - arg1: UByte, - timedInvokeTimeoutMs: Int? = null - ): TestEmitTestFabricScopedEventResponse { - val commandId = 21L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readBooleanAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBooleanAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readBitmap8Attribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeBitmap8Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBitmap8Attribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readBitmap16Attribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeBitmap16Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBitmap16Attribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readBitmap32Attribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeBitmap32Attribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBitmap32Attribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readBitmap64Attribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeBitmap64Attribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeBitmap64Attribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readInt8uAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt8uAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readInt16uAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeInt16uAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt16uAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readInt24uAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeInt24uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt24uAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readInt32uAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeInt32uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt32uAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readInt40uAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeInt40uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt40uAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readInt48uAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeInt48uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt48uAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readInt56uAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeInt56uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt56uAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readInt64uAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeInt64uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt64uAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readInt8sAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun writeInt8sAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt8sAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readInt16sAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeInt16sAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt16sAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readInt24sAttribute(): Int { - // Implementation needs to be added here - } - - suspend fun writeInt24sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt24sAttribute(minInterval: Int, maxInterval: Int): Int { - // Implementation needs to be added here - } - - suspend fun readInt32sAttribute(): Int { - // Implementation needs to be added here - } - - suspend fun writeInt32sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt32sAttribute(minInterval: Int, maxInterval: Int): Int { - // Implementation needs to be added here - } - - suspend fun readInt40sAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun writeInt40sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt40sAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readInt48sAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun writeInt48sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt48sAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readInt56sAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun writeInt56sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt56sAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readInt64sAttribute(): Long { - // Implementation needs to be added here - } - - suspend fun writeInt64sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeInt64sAttribute(minInterval: Int, maxInterval: Int): Long { - // Implementation needs to be added here - } - - suspend fun readEnum8Attribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeEnum8Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnum8Attribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readEnum16Attribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeEnum16Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnum16Attribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readFloatSingleAttribute(): Float { - // Implementation needs to be added here - } - - suspend fun writeFloatSingleAttribute(value: Float, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeFloatSingleAttribute(minInterval: Int, maxInterval: Int): Float { - // Implementation needs to be added here - } - - suspend fun readFloatDoubleAttribute(): Double { - // Implementation needs to be added here - } - - suspend fun writeFloatDoubleAttribute(value: Double, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeFloatDoubleAttribute(minInterval: Int, maxInterval: Int): Double { - // Implementation needs to be added here - } - - suspend fun readOctetStringAttribute(): OctetString { - // Implementation needs to be added here - } - - suspend fun writeOctetStringAttribute(value: ByteArray, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOctetStringAttribute(minInterval: Int, maxInterval: Int): OctetString { - // Implementation needs to be added here - } - - suspend fun readListInt8uAttribute(): ListInt8uAttribute { - // Implementation needs to be added here - } - - suspend fun writeListInt8uAttribute(value: List, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeListInt8uAttribute(minInterval: Int, maxInterval: Int): ListInt8uAttribute { - // Implementation needs to be added here - } - - suspend fun readListOctetStringAttribute(): ListOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun writeListOctetStringAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeListOctetStringAttribute( - minInterval: Int, - maxInterval: Int - ): ListOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun writeListStructOctetStringAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeListStructOctetStringAttribute( - minInterval: Int, - maxInterval: Int - ): ListStructOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun readLongOctetStringAttribute(): OctetString { - // Implementation needs to be added here - } - - suspend fun writeLongOctetStringAttribute(value: ByteArray, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLongOctetStringAttribute(minInterval: Int, maxInterval: Int): OctetString { - // Implementation needs to be added here - } - - suspend fun readCharStringAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeCharStringAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeCharStringAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLongCharStringAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun writeLongCharStringAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLongCharStringAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readEpochUsAttribute(): ULong { - // Implementation needs to be added here - } - - suspend fun writeEpochUsAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEpochUsAttribute(minInterval: Int, maxInterval: Int): ULong { - // Implementation needs to be added here - } - - suspend fun readEpochSAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun writeEpochSAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEpochSAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readVendorIdAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeVendorIdAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeVendorIdAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readListNullablesAndOptionalsStructAttribute(): - ListNullablesAndOptionalsStructAttribute { - // Implementation needs to be added here - } - - suspend fun writeListNullablesAndOptionalsStructAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeListNullablesAndOptionalsStructAttribute( - minInterval: Int, - maxInterval: Int - ): ListNullablesAndOptionalsStructAttribute { - // Implementation needs to be added here - } - - suspend fun readEnumAttrAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeEnumAttrAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeEnumAttrAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readStructAttrAttribute(): StructAttrAttribute { - // Implementation needs to be added here - } - - suspend fun writeStructAttrAttribute( - value: UnitTestingClusterSimpleStruct, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStructAttrAttribute( - minInterval: Int, - maxInterval: Int - ): StructAttrAttribute { - // Implementation needs to be added here - } - - suspend fun readRangeRestrictedInt8uAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeRangeRestrictedInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRangeRestrictedInt8uAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readRangeRestrictedInt8sAttribute(): Byte { - // Implementation needs to be added here - } - - suspend fun writeRangeRestrictedInt8sAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRangeRestrictedInt8sAttribute(minInterval: Int, maxInterval: Int): Byte { - // Implementation needs to be added here - } - - suspend fun readRangeRestrictedInt16uAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun writeRangeRestrictedInt16uAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRangeRestrictedInt16uAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readRangeRestrictedInt16sAttribute(): Short { - // Implementation needs to be added here - } - - suspend fun writeRangeRestrictedInt16sAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeRangeRestrictedInt16sAttribute(minInterval: Int, maxInterval: Int): Short { - // Implementation needs to be added here - } - - suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun writeListLongOctetStringAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeListLongOctetStringAttribute( - minInterval: Int, - maxInterval: Int - ): ListLongOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute { - // Implementation needs to be added here - } - - suspend fun readListFabricScopedAttributeWithFabricFilter( - isFabricFiltered: Boolean - ): ListFabricScopedAttribute { - // Implementation needs to be added here - } - - suspend fun writeListFabricScopedAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeListFabricScopedAttribute( - minInterval: Int, - maxInterval: Int - ): ListFabricScopedAttribute { - // Implementation needs to be added here - } - - suspend fun readTimedWriteBooleanAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeTimedWriteBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int) { - // Implementation needs to be added here - } - - suspend fun subscribeTimedWriteBooleanAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readGeneralErrorBooleanAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeGeneralErrorBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeGeneralErrorBooleanAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readClusterErrorBooleanAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeClusterErrorBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeClusterErrorBooleanAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readUnsupportedAttribute(): Boolean { - // Implementation needs to be added here - } - - suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeUnsupportedAttribute(minInterval: Int, maxInterval: Int): Boolean { - // Implementation needs to be added here - } - - suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableBooleanAttribute( - minInterval: Int, - maxInterval: Int - ): NullableBooleanAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { - // Implementation needs to be added here - } - - suspend fun writeNullableBitmap8Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableBitmap8Attribute( - minInterval: Int, - maxInterval: Int - ): NullableBitmap8Attribute { - // Implementation needs to be added here - } - - suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { - // Implementation needs to be added here - } - - suspend fun writeNullableBitmap16Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableBitmap16Attribute( - minInterval: Int, - maxInterval: Int - ): NullableBitmap16Attribute { - // Implementation needs to be added here - } - - suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { - // Implementation needs to be added here - } - - suspend fun writeNullableBitmap32Attribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableBitmap32Attribute( - minInterval: Int, - maxInterval: Int - ): NullableBitmap32Attribute { - // Implementation needs to be added here - } - - suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { - // Implementation needs to be added here - } - - suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableBitmap64Attribute( - minInterval: Int, - maxInterval: Int - ): NullableBitmap64Attribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt8uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt8uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt16uAttribute(value: UShort, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt16uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt16uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt24uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt24uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt24uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt32uAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt32uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt32uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt40uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt40uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt40uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt48uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt48uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt48uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt56uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt56uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt56uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt64uAttribute(value: ULong, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt64uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt64uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt8sAttribute(value: Byte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt8sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt8sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt16sAttribute(value: Short, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt16sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt16sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt24sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt24sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt24sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt32sAttribute(value: Int, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt32sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt32sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt40sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt40sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt40sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt48sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt48sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt48sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt56sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt56sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt56sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableInt64sAttribute(value: Long, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableInt64sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableInt64sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute { - // Implementation needs to be added here - } - - suspend fun writeNullableEnum8Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableEnum8Attribute( - minInterval: Int, - maxInterval: Int - ): NullableEnum8Attribute { - // Implementation needs to be added here - } - - suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute { - // Implementation needs to be added here - } - - suspend fun writeNullableEnum16Attribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableEnum16Attribute( - minInterval: Int, - maxInterval: Int - ): NullableEnum16Attribute { - // Implementation needs to be added here - } - - suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableFloatSingleAttribute(value: Float, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableFloatSingleAttribute( - minInterval: Int, - maxInterval: Int - ): NullableFloatSingleAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableFloatDoubleAttribute(value: Double, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableFloatDoubleAttribute( - minInterval: Int, - maxInterval: Int - ): NullableFloatDoubleAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableOctetStringAttribute( - value: ByteArray, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableOctetStringAttribute( - minInterval: Int, - maxInterval: Int - ): NullableOctetStringAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableCharStringAttribute(value: String, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableCharStringAttribute( - minInterval: Int, - maxInterval: Int - ): NullableCharStringAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableEnumAttrAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableEnumAttrAttribute( - minInterval: Int, - maxInterval: Int - ): NullableEnumAttrAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableStructAttribute(): NullableStructAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableStructAttribute( - value: UnitTestingClusterSimpleStruct, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableStructAttribute( - minInterval: Int, - maxInterval: Int - ): NullableStructAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableRangeRestrictedInt8uAttribute( - value: UByte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableRangeRestrictedInt8uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableRangeRestrictedInt8uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableRangeRestrictedInt8sAttribute( - value: Byte, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableRangeRestrictedInt8sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableRangeRestrictedInt8sAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableRangeRestrictedInt16uAttribute( - value: UShort, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableRangeRestrictedInt16uAttribute( - minInterval: Int, - maxInterval: Int - ): NullableRangeRestrictedInt16uAttribute { - // Implementation needs to be added here - } - - suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute { - // Implementation needs to be added here - } - - suspend fun writeNullableRangeRestrictedInt16sAttribute( - value: Short, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeNullableRangeRestrictedInt16sAttribute( - minInterval: Int, - maxInterval: Int - ): NullableRangeRestrictedInt16sAttribute { - // Implementation needs to be added here - } - - suspend fun readWriteOnlyInt8uAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeWriteOnlyInt8uAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeWriteOnlyInt8uAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 4294048773u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UserLabelCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UserLabelCluster.kt deleted file mode 100644 index 4b986531f5b412..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UserLabelCluster.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) { - class LabelListAttribute(val value: List) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readLabelListAttribute(): LabelListAttribute { - // Implementation needs to be added here - } - - suspend fun writeLabelListAttribute( - value: List, - timedWriteTimeoutMs: Int? = null - ) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeLabelListAttribute(minInterval: Int, maxInterval: Int): LabelListAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 65u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ValveConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ValveConfigurationAndControlCluster.kt deleted file mode 100644 index bdcc7781467968..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ValveConfigurationAndControlCluster.kt +++ /dev/null @@ -1,266 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class ValveConfigurationAndControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class OpenDurationAttribute(val value: UInt?) - - class AutoCloseTimeAttribute(val value: ULong?) - - class RemainingDurationAttribute(val value: UInt?) - - class CurrentStateAttribute(val value: UInt?) - - class TargetStateAttribute(val value: UInt?) - - class CurrentLevelAttribute(val value: UByte?) - - class TargetLevelAttribute(val value: UByte?) - - class OpenLevelAttribute(val value: UByte?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun open(openDuration: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun close(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun setLevel(level: UByte, openDuration: UInt?, timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readOpenDurationAttribute(): OpenDurationAttribute { - // Implementation needs to be added here - } - - suspend fun writeOpenDurationAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOpenDurationAttribute( - minInterval: Int, - maxInterval: Int - ): OpenDurationAttribute { - // Implementation needs to be added here - } - - suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAutoCloseTimeAttribute( - minInterval: Int, - maxInterval: Int - ): AutoCloseTimeAttribute { - // Implementation needs to be added here - } - - suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeRemainingDurationAttribute( - minInterval: Int, - maxInterval: Int - ): RemainingDurationAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentStateAttribute(): CurrentStateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentStateAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentStateAttribute { - // Implementation needs to be added here - } - - suspend fun readTargetStateAttribute(): TargetStateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTargetStateAttribute( - minInterval: Int, - maxInterval: Int - ): TargetStateAttribute { - // Implementation needs to be added here - } - - suspend fun readStartUpStateAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeStartUpStateAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeStartUpStateAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentLevelAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readTargetLevelAttribute(): TargetLevelAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTargetLevelAttribute( - minInterval: Int, - maxInterval: Int - ): TargetLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readOpenLevelAttribute(): OpenLevelAttribute { - // Implementation needs to be added here - } - - suspend fun writeOpenLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeOpenLevelAttribute(minInterval: Int, maxInterval: Int): OpenLevelAttribute { - // Implementation needs to be added here - } - - suspend fun readValveFaultAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeValveFaultAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 129u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WakeOnLanCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WakeOnLanCluster.kt deleted file mode 100644 index b879ef647988c4..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WakeOnLanCluster.kt +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readMACAddressAttribute(): CharString { - // Implementation needs to be added here - } - - suspend fun subscribeMACAddressAttribute(minInterval: Int, maxInterval: Int): CharString { - // Implementation needs to be added here - } - - suspend fun readLinkLocalAddressAttribute(): OctetString { - // Implementation needs to be added here - } - - suspend fun subscribeLinkLocalAddressAttribute(minInterval: Int, maxInterval: Int): OctetString { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 1283u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt deleted file mode 100644 index 3bae4cf3db3210..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt +++ /dev/null @@ -1,268 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class WiFiNetworkDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class BssidAttribute(val value: ByteArray?) - - class SecurityTypeAttribute(val value: UInt?) - - class WiFiVersionAttribute(val value: UInt?) - - class ChannelNumberAttribute(val value: UShort?) - - class RssiAttribute(val value: Byte?) - - class BeaconLostCountAttribute(val value: UInt?) - - class BeaconRxCountAttribute(val value: UInt?) - - class PacketMulticastRxCountAttribute(val value: UInt?) - - class PacketMulticastTxCountAttribute(val value: UInt?) - - class PacketUnicastRxCountAttribute(val value: UInt?) - - class PacketUnicastTxCountAttribute(val value: UInt?) - - class CurrentMaxRateAttribute(val value: ULong?) - - class OverrunCountAttribute(val value: ULong?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun resetCounts(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readBssidAttribute(): BssidAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBssidAttribute(minInterval: Int, maxInterval: Int): BssidAttribute { - // Implementation needs to be added here - } - - suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeSecurityTypeAttribute( - minInterval: Int, - maxInterval: Int - ): SecurityTypeAttribute { - // Implementation needs to be added here - } - - suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeWiFiVersionAttribute( - minInterval: Int, - maxInterval: Int - ): WiFiVersionAttribute { - // Implementation needs to be added here - } - - suspend fun readChannelNumberAttribute(): ChannelNumberAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeChannelNumberAttribute( - minInterval: Int, - maxInterval: Int - ): ChannelNumberAttribute { - // Implementation needs to be added here - } - - suspend fun readRssiAttribute(): RssiAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeRssiAttribute(minInterval: Int, maxInterval: Int): RssiAttribute { - // Implementation needs to be added here - } - - suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBeaconLostCountAttribute( - minInterval: Int, - maxInterval: Int - ): BeaconLostCountAttribute { - // Implementation needs to be added here - } - - suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeBeaconRxCountAttribute( - minInterval: Int, - maxInterval: Int - ): BeaconRxCountAttribute { - // Implementation needs to be added here - } - - suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePacketMulticastRxCountAttribute( - minInterval: Int, - maxInterval: Int - ): PacketMulticastRxCountAttribute { - // Implementation needs to be added here - } - - suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePacketMulticastTxCountAttribute( - minInterval: Int, - maxInterval: Int - ): PacketMulticastTxCountAttribute { - // Implementation needs to be added here - } - - suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePacketUnicastRxCountAttribute( - minInterval: Int, - maxInterval: Int - ): PacketUnicastRxCountAttribute { - // Implementation needs to be added here - } - - suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribePacketUnicastTxCountAttribute( - minInterval: Int, - maxInterval: Int - ): PacketUnicastTxCountAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentMaxRateAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentMaxRateAttribute { - // Implementation needs to be added here - } - - suspend fun readOverrunCountAttribute(): OverrunCountAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeOverrunCountAttribute( - minInterval: Int, - maxInterval: Int - ): OverrunCountAttribute { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 54u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WindowCoveringCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WindowCoveringCluster.kt deleted file mode 100644 index 644a365b3c2440..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WindowCoveringCluster.kt +++ /dev/null @@ -1,411 +0,0 @@ -/* - * - * 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. - */ - -package matter.devicecontroller.cluster.clusters - -import matter.controller.MatterController -import matter.devicecontroller.cluster.structs.* - -class WindowCoveringCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class CurrentPositionLiftAttribute(val value: UShort?) - - class CurrentPositionTiltAttribute(val value: UShort?) - - class CurrentPositionLiftPercentageAttribute(val value: UByte?) - - class CurrentPositionTiltPercentageAttribute(val value: UByte?) - - class TargetPositionLiftPercent100thsAttribute(val value: UShort?) - - class TargetPositionTiltPercent100thsAttribute(val value: UShort?) - - class CurrentPositionLiftPercent100thsAttribute(val value: UShort?) - - class CurrentPositionTiltPercent100thsAttribute(val value: UShort?) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun upOrOpen(timedInvokeTimeoutMs: Int? = null) { - val commandId = 0L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun downOrClose(timedInvokeTimeoutMs: Int? = null) { - val commandId = 1L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun stopMotion(timedInvokeTimeoutMs: Int? = null) { - val commandId = 2L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun goToLiftValue(liftValue: UShort, timedInvokeTimeoutMs: Int? = null) { - val commandId = 4L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun goToLiftPercentage( - liftPercent100thsValue: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 5L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun goToTiltValue(tiltValue: UShort, timedInvokeTimeoutMs: Int? = null) { - val commandId = 7L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun goToTiltPercentage( - tiltPercent100thsValue: UShort, - timedInvokeTimeoutMs: Int? = null - ) { - val commandId = 8L - - if (timedInvokeTimeoutMs != null) { - // Do the action with timedInvokeTimeoutMs - } else { - // Do the action without timedInvokeTimeoutMs - } - } - - suspend fun readTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readPhysicalClosedLimitLiftAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePhysicalClosedLimitLiftAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readPhysicalClosedLimitTiltAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribePhysicalClosedLimitTiltAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionLiftAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPositionLiftAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionTiltAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPositionTiltAttribute { - // Implementation needs to be added here - } - - suspend fun readNumberOfActuationsLiftAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfActuationsLiftAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readNumberOfActuationsTiltAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeNumberOfActuationsTiltAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readConfigStatusAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeConfigStatusAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionLiftPercentageAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPositionLiftPercentageAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionTiltPercentageAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPositionTiltPercentageAttribute { - // Implementation needs to be added here - } - - suspend fun readOperationalStatusAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeOperationalStatusAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readTargetPositionLiftPercent100thsAttribute(): - TargetPositionLiftPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTargetPositionLiftPercent100thsAttribute( - minInterval: Int, - maxInterval: Int - ): TargetPositionLiftPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun readTargetPositionTiltPercent100thsAttribute(): - TargetPositionTiltPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeTargetPositionTiltPercent100thsAttribute( - minInterval: Int, - maxInterval: Int - ): TargetPositionTiltPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun readEndProductTypeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun subscribeEndProductTypeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionLiftPercent100thsAttribute(): - CurrentPositionLiftPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionLiftPercent100thsAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPositionLiftPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun readCurrentPositionTiltPercent100thsAttribute(): - CurrentPositionTiltPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeCurrentPositionTiltPercent100thsAttribute( - minInterval: Int, - maxInterval: Int - ): CurrentPositionTiltPercent100thsAttribute { - // Implementation needs to be added here - } - - suspend fun readInstalledOpenLimitLiftAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeInstalledOpenLimitLiftAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readInstalledClosedLimitLiftAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeInstalledClosedLimitLiftAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readInstalledOpenLimitTiltAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeInstalledOpenLimitTiltAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readInstalledClosedLimitTiltAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeInstalledClosedLimitTiltAttribute( - minInterval: Int, - maxInterval: Int - ): UShort { - // Implementation needs to be added here - } - - suspend fun readModeAttribute(): UByte { - // Implementation needs to be added here - } - - suspend fun writeModeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) { - if (timedWriteTimeoutMs != null) { - // Do the action with timedWriteTimeoutMs - } else { - // Do the action without timedWriteTimeoutMs - } - } - - suspend fun subscribeModeAttribute(minInterval: Int, maxInterval: Int): UByte { - // Implementation needs to be added here - } - - suspend fun readSafetyStatusAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeSafetyStatusAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeGeneratedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): GeneratedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAcceptedCommandListAttribute( - minInterval: Int, - maxInterval: Int - ): AcceptedCommandListAttribute { - // Implementation needs to be added here - } - - suspend fun readEventListAttribute(): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeEventListAttribute(minInterval: Int, maxInterval: Int): EventListAttribute { - // Implementation needs to be added here - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun subscribeAttributeListAttribute( - minInterval: Int, - maxInterval: Int - ): AttributeListAttribute { - // Implementation needs to be added here - } - - suspend fun readFeatureMapAttribute(): UInt { - // Implementation needs to be added here - } - - suspend fun subscribeFeatureMapAttribute(minInterval: Int, maxInterval: Int): UInt { - // Implementation needs to be added here - } - - suspend fun readClusterRevisionAttribute(): UShort { - // Implementation needs to be added here - } - - suspend fun subscribeClusterRevisionAttribute(minInterval: Int, maxInterval: Int): UShort { - // Implementation needs to be added here - } - - companion object { - const val CLUSTER_ID: UInt = 258u - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni deleted file mode 100644 index bbcafb5fbff65a..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni +++ /dev/null @@ -1,306 +0,0 @@ -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -matter_structs_sources = [ - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterAttributeValuePair.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterExtensionFieldSet.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ScenesClusterSceneInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt", -] - -matter_eventstructs_sources = [ - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanSensorConfigurationClusterAlarmsStateChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt", -] - -matter_clusters_sources = [ - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccessControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AccountLoginCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActionsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AdministratorCommissioningCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AirQualityCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationBasicCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ApplicationLauncherCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/AudioOutputCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BallastConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BarrierControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BasicInformationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BinaryInputBasicCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BindingCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanSensorConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BooleanStateCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ChannelCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ColorControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentAppObserverCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ContentLauncherCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DemandResponseLoadControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DescriptorCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DeviceEnergyManagementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DiagnosticLogsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherAlarmCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DishwasherModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/DoorLockCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EnergyEvseCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FanControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FaultInjectionCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FixedLabelCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FlowMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralCommissioningCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GeneralDiagnosticsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupKeyManagementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/GroupsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/HepaFilterMonitoringCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IcdManagementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IdentifyCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/IlluminanceMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/KeypadInputCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryDryerControlsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherControlsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LaundryWasherModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LevelControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LocalizationConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/LowPowerCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaInputCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MediaPlaybackCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/MicrowaveOvenModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ModeSelectCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NetworkCommissioningCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OccupancySensingCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OnOffSwitchConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalCredentialsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OperationalStateCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenCavityOperationalStateCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OvenModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PowerSourceConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PressureMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyDiscoveryCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ProxyValidCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PulseWidthModulationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/PumpConfigurationAndControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RadonConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAlarmCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RelativeHumidityMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcCleanModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcOperationalStateCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/RvcRunModeCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SampleMeiCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ScenesCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SmokeCoAlarmCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SoftwareDiagnosticsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/SwitchCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TargetNavigatorCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TemperatureMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeFormatLocalizationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimerCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TimeSynchronizationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitLocalizationCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UnitTestingCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/UserLabelCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ValveConfigurationAndControlCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WakeOnLanCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/WindowCoveringCluster.kt", -] \ No newline at end of file diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterScopedLoadControlEventStruct.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterScopedLoadControlEventStruct.kt deleted file mode 100644 index f9ea556026897f..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/DemandResponseLoadControlClusterScopedLoadControlEventStruct.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * 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. - */ -package matter.devicecontroller.cluster.structs - -import matter.devicecontroller.cluster.* -import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvReader -import matter.tlv.TlvWriter - -class DemandResponseLoadControlClusterScopedLoadControlEventStruct( - val eventID: ByteArray, - val programControl: ByteArray, - val control: UInt, - val deviceClass: ULong, - val enrollmentGroup: UByte?, - val criticality: UInt, - val startTime: UInt?, - val transitions: List, - val fabricIndex: UByte -) { - override fun toString(): String = buildString { - append("DemandResponseLoadControlClusterScopedLoadControlEventStruct {\n") - append("\teventID : $eventID\n") - append("\tprogramControl : $programControl\n") - append("\tcontrol : $control\n") - append("\tdeviceClass : $deviceClass\n") - append("\tenrollmentGroup : $enrollmentGroup\n") - append("\tcriticality : $criticality\n") - append("\tstartTime : $startTime\n") - append("\ttransitions : $transitions\n") - append("\tfabricIndex : $fabricIndex\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_EVENT_I_D), eventID) - put(ContextSpecificTag(TAG_PROGRAM_CONTROL), programControl) - put(ContextSpecificTag(TAG_CONTROL), control) - put(ContextSpecificTag(TAG_DEVICE_CLASS), deviceClass) - if (enrollmentGroup != null) { - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) - } else { - putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } - put(ContextSpecificTag(TAG_CRITICALITY), criticality) - if (startTime != null) { - put(ContextSpecificTag(TAG_START_TIME), startTime) - } else { - putNull(ContextSpecificTag(TAG_START_TIME)) - } - startArray(ContextSpecificTag(TAG_TRANSITIONS)) - for (item in transitions.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - endStructure() - } - } - - companion object { - private const val TAG_EVENT_I_D = 0 - private const val TAG_PROGRAM_CONTROL = 1 - private const val TAG_CONTROL = 2 - private const val TAG_DEVICE_CLASS = 3 - private const val TAG_ENROLLMENT_GROUP = 4 - private const val TAG_CRITICALITY = 5 - private const val TAG_START_TIME = 6 - private const val TAG_TRANSITIONS = 7 - private const val TAG_FABRIC_INDEX = 254 - - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterScopedLoadControlEventStruct { - tlvReader.enterStructure(tlvTag) - val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programControl = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_CONTROL)) - val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val deviceClass = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - - tlvReader.exitContainer() - - return DemandResponseLoadControlClusterScopedLoadControlEventStruct( - eventID, - programControl, - control, - deviceClass, - enrollmentGroup, - criticality, - startTime, - transitions, - fabricIndex - ) - } - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt deleted file mode 100644 index ecd2bf08eb8fcb..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * 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. - */ -package matter.devicecontroller.cluster.structs - -import matter.devicecontroller.cluster.* -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvReader -import matter.tlv.TlvWriter - -class ThermostatClusterThermostatScheduleTransition( - val transitionTime: UShort, - val heatSetpoint: Short?, - val coolSetpoint: Short? -) { - override fun toString(): String = buildString { - append("ThermostatClusterThermostatScheduleTransition {\n") - append("\ttransitionTime : $transitionTime\n") - append("\theatSetpoint : $heatSetpoint\n") - append("\tcoolSetpoint : $coolSetpoint\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) - if (heatSetpoint != null) { - put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) - } else { - putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } - if (coolSetpoint != null) { - put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) - } else { - putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - } - endStructure() - } - } - - companion object { - private const val TAG_TRANSITION_TIME = 0 - private const val TAG_HEAT_SETPOINT = 1 - private const val TAG_COOL_SETPOINT = 2 - - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterThermostatScheduleTransition { - tlvReader.enterStructure(tlvTag) - val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - - tlvReader.exitContainer() - - return ThermostatClusterThermostatScheduleTransition( - transitionTime, - heatSetpoint, - coolSetpoint - ) - } - } -} diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index aee716ee76a3f3..e87c3ea5961c68 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -19345,6 +19345,810 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } break; } + case app::Clusters::ElectricalEnergyMeasurement::Id: { + using namespace app::Clusters::ElectricalEnergyMeasurement; + switch (aPath.mAttributeId) + { + case Attributes::Accuracy::Id: { + using TypeInfo = Attributes::Accuracy::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + jobject value_measurementType; + std::string value_measurementTypeClassName = "java/lang/Integer"; + std::string value_measurementTypeCtorSignature = "(I)V"; + jint jnivalue_measurementType = static_cast(cppValue.measurementType); + chip::JniReferences::GetInstance().CreateBoxedObject(value_measurementTypeClassName.c_str(), + value_measurementTypeCtorSignature.c_str(), + jnivalue_measurementType, value_measurementType); + jobject value_measured; + std::string value_measuredClassName = "java/lang/Boolean"; + std::string value_measuredCtorSignature = "(Z)V"; + jboolean jnivalue_measured = static_cast(cppValue.measured); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_measuredClassName.c_str(), value_measuredCtorSignature.c_str(), jnivalue_measured, value_measured); + jobject value_minMeasuredValue; + std::string value_minMeasuredValueClassName = "java/lang/Long"; + std::string value_minMeasuredValueCtorSignature = "(J)V"; + jlong jnivalue_minMeasuredValue = static_cast(cppValue.minMeasuredValue); + chip::JniReferences::GetInstance().CreateBoxedObject(value_minMeasuredValueClassName.c_str(), + value_minMeasuredValueCtorSignature.c_str(), + jnivalue_minMeasuredValue, value_minMeasuredValue); + jobject value_maxMeasuredValue; + std::string value_maxMeasuredValueClassName = "java/lang/Long"; + std::string value_maxMeasuredValueCtorSignature = "(J)V"; + jlong jnivalue_maxMeasuredValue = static_cast(cppValue.maxMeasuredValue); + chip::JniReferences::GetInstance().CreateBoxedObject(value_maxMeasuredValueClassName.c_str(), + value_maxMeasuredValueCtorSignature.c_str(), + jnivalue_maxMeasuredValue, value_maxMeasuredValue); + jobject value_accuracyRanges; + chip::JniReferences::GetInstance().CreateArrayList(value_accuracyRanges); + + auto iter_value_accuracyRanges_1 = cppValue.accuracyRanges.begin(); + while (iter_value_accuracyRanges_1.Next()) + { + auto & entry_1 = iter_value_accuracyRanges_1.GetValue(); + jobject newElement_1; + jobject newElement_1_rangeMin; + std::string newElement_1_rangeMinClassName = "java/lang/Long"; + std::string newElement_1_rangeMinCtorSignature = "(J)V"; + jlong jninewElement_1_rangeMin = static_cast(entry_1.rangeMin); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_rangeMinClassName.c_str(), + newElement_1_rangeMinCtorSignature.c_str(), + jninewElement_1_rangeMin, newElement_1_rangeMin); + jobject newElement_1_rangeMax; + std::string newElement_1_rangeMaxClassName = "java/lang/Long"; + std::string newElement_1_rangeMaxCtorSignature = "(J)V"; + jlong jninewElement_1_rangeMax = static_cast(entry_1.rangeMax); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_rangeMaxClassName.c_str(), + newElement_1_rangeMaxCtorSignature.c_str(), + jninewElement_1_rangeMax, newElement_1_rangeMax); + jobject newElement_1_percentMax; + if (!entry_1.percentMax.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_1_percentMax); + } + else + { + jobject newElement_1_percentMaxInsideOptional; + std::string newElement_1_percentMaxInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_1_percentMaxInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_1_percentMaxInsideOptional = static_cast(entry_1.percentMax.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_percentMaxInsideOptionalClassName.c_str(), + newElement_1_percentMaxInsideOptionalCtorSignature.c_str(), jninewElement_1_percentMaxInsideOptional, + newElement_1_percentMaxInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_1_percentMaxInsideOptional, + newElement_1_percentMax); + } + jobject newElement_1_percentMin; + if (!entry_1.percentMin.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_1_percentMin); + } + else + { + jobject newElement_1_percentMinInsideOptional; + std::string newElement_1_percentMinInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_1_percentMinInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_1_percentMinInsideOptional = static_cast(entry_1.percentMin.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_percentMinInsideOptionalClassName.c_str(), + newElement_1_percentMinInsideOptionalCtorSignature.c_str(), jninewElement_1_percentMinInsideOptional, + newElement_1_percentMinInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_1_percentMinInsideOptional, + newElement_1_percentMin); + } + jobject newElement_1_percentTypical; + if (!entry_1.percentTypical.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_1_percentTypical); + } + else + { + jobject newElement_1_percentTypicalInsideOptional; + std::string newElement_1_percentTypicalInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_1_percentTypicalInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_1_percentTypicalInsideOptional = static_cast(entry_1.percentTypical.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_percentTypicalInsideOptionalClassName.c_str(), + newElement_1_percentTypicalInsideOptionalCtorSignature.c_str(), + jninewElement_1_percentTypicalInsideOptional, newElement_1_percentTypicalInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_1_percentTypicalInsideOptional, + newElement_1_percentTypical); + } + jobject newElement_1_fixedMax; + if (!entry_1.fixedMax.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_1_fixedMax); + } + else + { + jobject newElement_1_fixedMaxInsideOptional; + std::string newElement_1_fixedMaxInsideOptionalClassName = "java/lang/Long"; + std::string newElement_1_fixedMaxInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_1_fixedMaxInsideOptional = static_cast(entry_1.fixedMax.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_fixedMaxInsideOptionalClassName.c_str(), + newElement_1_fixedMaxInsideOptionalCtorSignature.c_str(), jninewElement_1_fixedMaxInsideOptional, + newElement_1_fixedMaxInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_1_fixedMaxInsideOptional, newElement_1_fixedMax); + } + jobject newElement_1_fixedMin; + if (!entry_1.fixedMin.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_1_fixedMin); + } + else + { + jobject newElement_1_fixedMinInsideOptional; + std::string newElement_1_fixedMinInsideOptionalClassName = "java/lang/Long"; + std::string newElement_1_fixedMinInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_1_fixedMinInsideOptional = static_cast(entry_1.fixedMin.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_fixedMinInsideOptionalClassName.c_str(), + newElement_1_fixedMinInsideOptionalCtorSignature.c_str(), jninewElement_1_fixedMinInsideOptional, + newElement_1_fixedMinInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_1_fixedMinInsideOptional, newElement_1_fixedMin); + } + jobject newElement_1_fixedTypical; + if (!entry_1.fixedTypical.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_1_fixedTypical); + } + else + { + jobject newElement_1_fixedTypicalInsideOptional; + std::string newElement_1_fixedTypicalInsideOptionalClassName = "java/lang/Long"; + std::string newElement_1_fixedTypicalInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_1_fixedTypicalInsideOptional = static_cast(entry_1.fixedTypical.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_1_fixedTypicalInsideOptionalClassName.c_str(), + newElement_1_fixedTypicalInsideOptionalCtorSignature.c_str(), jninewElement_1_fixedTypicalInsideOptional, + newElement_1_fixedTypicalInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_1_fixedTypicalInsideOptional, + newElement_1_fixedTypical); + } + + jclass measurementAccuracyRangeStructStructClass_2; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct", + measurementAccuracyRangeStructStructClass_2); + if (err != CHIP_NO_ERROR) + { + ChipLogError( + Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct"); + return nullptr; + } + jmethodID measurementAccuracyRangeStructStructCtor_2 = + env->GetMethodID(measurementAccuracyRangeStructStructClass_2, "", + "(Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (measurementAccuracyRangeStructStructCtor_2 == nullptr) + { + ChipLogError( + Zcl, + "Could not find ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct constructor"); + return nullptr; + } + + newElement_1 = env->NewObject( + measurementAccuracyRangeStructStructClass_2, measurementAccuracyRangeStructStructCtor_2, newElement_1_rangeMin, + newElement_1_rangeMax, newElement_1_percentMax, newElement_1_percentMin, newElement_1_percentTypical, + newElement_1_fixedMax, newElement_1_fixedMin, newElement_1_fixedTypical); + chip::JniReferences::GetInstance().AddToList(value_accuracyRanges, newElement_1); + } + + jclass measurementAccuracyStructStructClass_0; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct", + measurementAccuracyStructStructClass_0); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct"); + return nullptr; + } + jmethodID measurementAccuracyStructStructCtor_0 = + env->GetMethodID(measurementAccuracyStructStructClass_0, "", + "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/ArrayList;)V"); + if (measurementAccuracyStructStructCtor_0 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct constructor"); + return nullptr; + } + + value = + env->NewObject(measurementAccuracyStructStructClass_0, measurementAccuracyStructStructCtor_0, value_measurementType, + value_measured, value_minMeasuredValue, value_maxMeasuredValue, value_accuracyRanges); + return value; + } + case Attributes::CumulativeEnergyImported::Id: { + using TypeInfo = Attributes::CumulativeEnergyImported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_energy; + std::string value_energyClassName = "java/lang/Long"; + std::string value_energyCtorSignature = "(J)V"; + jlong jnivalue_energy = static_cast(cppValue.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyClassName.c_str(), value_energyCtorSignature.c_str(), jnivalue_energy, value_energy); + jobject value_startTimestamp; + if (!cppValue.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startTimestamp); + } + else + { + jobject value_startTimestampInsideOptional; + std::string value_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startTimestampInsideOptional = static_cast(cppValue.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startTimestampInsideOptionalClassName.c_str(), + value_startTimestampInsideOptionalCtorSignature.c_str(), jnivalue_startTimestampInsideOptional, + value_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startTimestampInsideOptional, value_startTimestamp); + } + jobject value_endTimestamp; + if (!cppValue.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endTimestamp); + } + else + { + jobject value_endTimestampInsideOptional; + std::string value_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endTimestampInsideOptional = static_cast(cppValue.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endTimestampInsideOptionalClassName.c_str(), value_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_endTimestampInsideOptional, value_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endTimestampInsideOptional, value_endTimestamp); + } + jobject value_startSystime; + if (!cppValue.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startSystime); + } + else + { + jobject value_startSystimeInsideOptional; + std::string value_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startSystimeInsideOptional = static_cast(cppValue.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startSystimeInsideOptionalClassName.c_str(), value_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_startSystimeInsideOptional, value_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startSystimeInsideOptional, value_startSystime); + } + jobject value_endSystime; + if (!cppValue.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endSystime); + } + else + { + jobject value_endSystimeInsideOptional; + std::string value_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endSystimeInsideOptional = static_cast(cppValue.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endSystimeInsideOptionalClassName.c_str(), value_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_endSystimeInsideOptional, value_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endSystimeInsideOptional, value_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value = env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, value_energy, + value_startTimestamp, value_endTimestamp, value_startSystime, value_endSystime); + } + return value; + } + case Attributes::CumulativeEnergyExported::Id: { + using TypeInfo = Attributes::CumulativeEnergyExported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_energy; + std::string value_energyClassName = "java/lang/Long"; + std::string value_energyCtorSignature = "(J)V"; + jlong jnivalue_energy = static_cast(cppValue.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyClassName.c_str(), value_energyCtorSignature.c_str(), jnivalue_energy, value_energy); + jobject value_startTimestamp; + if (!cppValue.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startTimestamp); + } + else + { + jobject value_startTimestampInsideOptional; + std::string value_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startTimestampInsideOptional = static_cast(cppValue.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startTimestampInsideOptionalClassName.c_str(), + value_startTimestampInsideOptionalCtorSignature.c_str(), jnivalue_startTimestampInsideOptional, + value_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startTimestampInsideOptional, value_startTimestamp); + } + jobject value_endTimestamp; + if (!cppValue.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endTimestamp); + } + else + { + jobject value_endTimestampInsideOptional; + std::string value_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endTimestampInsideOptional = static_cast(cppValue.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endTimestampInsideOptionalClassName.c_str(), value_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_endTimestampInsideOptional, value_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endTimestampInsideOptional, value_endTimestamp); + } + jobject value_startSystime; + if (!cppValue.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startSystime); + } + else + { + jobject value_startSystimeInsideOptional; + std::string value_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startSystimeInsideOptional = static_cast(cppValue.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startSystimeInsideOptionalClassName.c_str(), value_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_startSystimeInsideOptional, value_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startSystimeInsideOptional, value_startSystime); + } + jobject value_endSystime; + if (!cppValue.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endSystime); + } + else + { + jobject value_endSystimeInsideOptional; + std::string value_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endSystimeInsideOptional = static_cast(cppValue.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endSystimeInsideOptionalClassName.c_str(), value_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_endSystimeInsideOptional, value_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endSystimeInsideOptional, value_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value = env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, value_energy, + value_startTimestamp, value_endTimestamp, value_startSystime, value_endSystime); + } + return value; + } + case Attributes::PeriodicEnergyImported::Id: { + using TypeInfo = Attributes::PeriodicEnergyImported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_energy; + std::string value_energyClassName = "java/lang/Long"; + std::string value_energyCtorSignature = "(J)V"; + jlong jnivalue_energy = static_cast(cppValue.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyClassName.c_str(), value_energyCtorSignature.c_str(), jnivalue_energy, value_energy); + jobject value_startTimestamp; + if (!cppValue.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startTimestamp); + } + else + { + jobject value_startTimestampInsideOptional; + std::string value_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startTimestampInsideOptional = static_cast(cppValue.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startTimestampInsideOptionalClassName.c_str(), + value_startTimestampInsideOptionalCtorSignature.c_str(), jnivalue_startTimestampInsideOptional, + value_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startTimestampInsideOptional, value_startTimestamp); + } + jobject value_endTimestamp; + if (!cppValue.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endTimestamp); + } + else + { + jobject value_endTimestampInsideOptional; + std::string value_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endTimestampInsideOptional = static_cast(cppValue.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endTimestampInsideOptionalClassName.c_str(), value_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_endTimestampInsideOptional, value_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endTimestampInsideOptional, value_endTimestamp); + } + jobject value_startSystime; + if (!cppValue.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startSystime); + } + else + { + jobject value_startSystimeInsideOptional; + std::string value_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startSystimeInsideOptional = static_cast(cppValue.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startSystimeInsideOptionalClassName.c_str(), value_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_startSystimeInsideOptional, value_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startSystimeInsideOptional, value_startSystime); + } + jobject value_endSystime; + if (!cppValue.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endSystime); + } + else + { + jobject value_endSystimeInsideOptional; + std::string value_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endSystimeInsideOptional = static_cast(cppValue.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endSystimeInsideOptionalClassName.c_str(), value_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_endSystimeInsideOptional, value_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endSystimeInsideOptional, value_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value = env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, value_energy, + value_startTimestamp, value_endTimestamp, value_startSystime, value_endSystime); + } + return value; + } + case Attributes::PeriodicEnergyExported::Id: { + using TypeInfo = Attributes::PeriodicEnergyExported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_energy; + std::string value_energyClassName = "java/lang/Long"; + std::string value_energyCtorSignature = "(J)V"; + jlong jnivalue_energy = static_cast(cppValue.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyClassName.c_str(), value_energyCtorSignature.c_str(), jnivalue_energy, value_energy); + jobject value_startTimestamp; + if (!cppValue.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startTimestamp); + } + else + { + jobject value_startTimestampInsideOptional; + std::string value_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startTimestampInsideOptional = static_cast(cppValue.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startTimestampInsideOptionalClassName.c_str(), + value_startTimestampInsideOptionalCtorSignature.c_str(), jnivalue_startTimestampInsideOptional, + value_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startTimestampInsideOptional, value_startTimestamp); + } + jobject value_endTimestamp; + if (!cppValue.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endTimestamp); + } + else + { + jobject value_endTimestampInsideOptional; + std::string value_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endTimestampInsideOptional = static_cast(cppValue.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endTimestampInsideOptionalClassName.c_str(), value_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_endTimestampInsideOptional, value_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endTimestampInsideOptional, value_endTimestamp); + } + jobject value_startSystime; + if (!cppValue.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_startSystime); + } + else + { + jobject value_startSystimeInsideOptional; + std::string value_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_startSystimeInsideOptional = static_cast(cppValue.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_startSystimeInsideOptionalClassName.c_str(), value_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_startSystimeInsideOptional, value_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_startSystimeInsideOptional, value_startSystime); + } + jobject value_endSystime; + if (!cppValue.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_endSystime); + } + else + { + jobject value_endSystimeInsideOptional; + std::string value_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_endSystimeInsideOptional = static_cast(cppValue.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_endSystimeInsideOptionalClassName.c_str(), value_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_endSystimeInsideOptional, value_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_endSystimeInsideOptional, value_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value = env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, value_energy, + value_startTimestamp, value_endTimestamp, value_startSystime, value_endSystime); + } + 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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_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"; + jlong jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, 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"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + break; + } + break; + } case app::Clusters::DemandResponseLoadControl::Id: { using namespace app::Clusters::DemandResponseLoadControl; switch (aPath.mAttributeId) diff --git a/src/controller/java/zap-generated/CHIPClientCallbacks.h b/src/controller/java/zap-generated/CHIPClientCallbacks.h index 09e7aaeb545cc5..fdc34c7fee5595 100644 --- a/src/controller/java/zap-generated/CHIPClientCallbacks.h +++ b/src/controller/java/zap-generated/CHIPClientCallbacks.h @@ -729,6 +729,14 @@ typedef void (*ValveConfigurationAndControlEventListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*ValveConfigurationAndControlAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*ElectricalEnergyMeasurementGeneratedCommandListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*ElectricalEnergyMeasurementAcceptedCommandListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*ElectricalEnergyMeasurementEventListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*ElectricalEnergyMeasurementAttributeListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); typedef void (*DemandResponseLoadControlLoadControlProgramsListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList< diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 4b67ac79cd7b9f..4dd1ffd1e2e2c1 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -3837,6 +3837,580 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } break; } + case app::Clusters::ElectricalEnergyMeasurement::Id: { + using namespace app::Clusters::ElectricalEnergyMeasurement; + switch (aPath.mEventId) + { + case Events::CumulativeEnergyMeasured::Id: { + Events::CumulativeEnergyMeasured::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_energyImported; + if (!cppValue.energyImported.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImported); + } + else + { + jobject value_energyImportedInsideOptional; + jobject value_energyImportedInsideOptional_energy; + std::string value_energyImportedInsideOptional_energyClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_energyCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_energy = static_cast(cppValue.energyImported.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_energyClassName.c_str(), + value_energyImportedInsideOptional_energyCtorSignature.c_str(), jnivalue_energyImportedInsideOptional_energy, + value_energyImportedInsideOptional_energy); + jobject value_energyImportedInsideOptional_startTimestamp; + if (!cppValue.energyImported.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_startTimestamp); + } + else + { + jobject value_energyImportedInsideOptional_startTimestampInsideOptional; + std::string value_energyImportedInsideOptional_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_startTimestampInsideOptional = + static_cast(cppValue.energyImported.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_startTimestampInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_startTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_startTimestampInsideOptional, + value_energyImportedInsideOptional_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional( + value_energyImportedInsideOptional_startTimestampInsideOptional, + value_energyImportedInsideOptional_startTimestamp); + } + jobject value_energyImportedInsideOptional_endTimestamp; + if (!cppValue.energyImported.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_endTimestamp); + } + else + { + jobject value_energyImportedInsideOptional_endTimestampInsideOptional; + std::string value_energyImportedInsideOptional_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_endTimestampInsideOptional = + static_cast(cppValue.energyImported.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_endTimestampInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_endTimestampInsideOptional, + value_energyImportedInsideOptional_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional_endTimestampInsideOptional, + value_energyImportedInsideOptional_endTimestamp); + } + jobject value_energyImportedInsideOptional_startSystime; + if (!cppValue.energyImported.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_startSystime); + } + else + { + jobject value_energyImportedInsideOptional_startSystimeInsideOptional; + std::string value_energyImportedInsideOptional_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_startSystimeInsideOptional = + static_cast(cppValue.energyImported.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_startSystimeInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_startSystimeInsideOptional, + value_energyImportedInsideOptional_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional_startSystimeInsideOptional, + value_energyImportedInsideOptional_startSystime); + } + jobject value_energyImportedInsideOptional_endSystime; + if (!cppValue.energyImported.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_endSystime); + } + else + { + jobject value_energyImportedInsideOptional_endSystimeInsideOptional; + std::string value_energyImportedInsideOptional_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_endSystimeInsideOptional = + static_cast(cppValue.energyImported.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_endSystimeInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_endSystimeInsideOptional, + value_energyImportedInsideOptional_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional_endSystimeInsideOptional, + value_energyImportedInsideOptional_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value_energyImportedInsideOptional = + env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, + value_energyImportedInsideOptional_energy, value_energyImportedInsideOptional_startTimestamp, + value_energyImportedInsideOptional_endTimestamp, value_energyImportedInsideOptional_startSystime, + value_energyImportedInsideOptional_endSystime); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional, value_energyImported); + } + + jobject value_energyExported; + if (!cppValue.energyExported.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExported); + } + else + { + jobject value_energyExportedInsideOptional; + jobject value_energyExportedInsideOptional_energy; + std::string value_energyExportedInsideOptional_energyClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_energyCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_energy = static_cast(cppValue.energyExported.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_energyClassName.c_str(), + value_energyExportedInsideOptional_energyCtorSignature.c_str(), jnivalue_energyExportedInsideOptional_energy, + value_energyExportedInsideOptional_energy); + jobject value_energyExportedInsideOptional_startTimestamp; + if (!cppValue.energyExported.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_startTimestamp); + } + else + { + jobject value_energyExportedInsideOptional_startTimestampInsideOptional; + std::string value_energyExportedInsideOptional_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_startTimestampInsideOptional = + static_cast(cppValue.energyExported.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_startTimestampInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_startTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_startTimestampInsideOptional, + value_energyExportedInsideOptional_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional( + value_energyExportedInsideOptional_startTimestampInsideOptional, + value_energyExportedInsideOptional_startTimestamp); + } + jobject value_energyExportedInsideOptional_endTimestamp; + if (!cppValue.energyExported.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_endTimestamp); + } + else + { + jobject value_energyExportedInsideOptional_endTimestampInsideOptional; + std::string value_energyExportedInsideOptional_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_endTimestampInsideOptional = + static_cast(cppValue.energyExported.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_endTimestampInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_endTimestampInsideOptional, + value_energyExportedInsideOptional_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional_endTimestampInsideOptional, + value_energyExportedInsideOptional_endTimestamp); + } + jobject value_energyExportedInsideOptional_startSystime; + if (!cppValue.energyExported.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_startSystime); + } + else + { + jobject value_energyExportedInsideOptional_startSystimeInsideOptional; + std::string value_energyExportedInsideOptional_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_startSystimeInsideOptional = + static_cast(cppValue.energyExported.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_startSystimeInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_startSystimeInsideOptional, + value_energyExportedInsideOptional_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional_startSystimeInsideOptional, + value_energyExportedInsideOptional_startSystime); + } + jobject value_energyExportedInsideOptional_endSystime; + if (!cppValue.energyExported.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_endSystime); + } + else + { + jobject value_energyExportedInsideOptional_endSystimeInsideOptional; + std::string value_energyExportedInsideOptional_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_endSystimeInsideOptional = + static_cast(cppValue.energyExported.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_endSystimeInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_endSystimeInsideOptional, + value_energyExportedInsideOptional_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional_endSystimeInsideOptional, + value_energyExportedInsideOptional_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value_energyExportedInsideOptional = + env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, + value_energyExportedInsideOptional_energy, value_energyExportedInsideOptional_startTimestamp, + value_energyExportedInsideOptional_endTimestamp, value_energyExportedInsideOptional_startSystime, + value_energyExportedInsideOptional_endSystime); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional, value_energyExported); + } + + jclass cumulativeEnergyMeasuredStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent", + cumulativeEnergyMeasuredStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError( + Zcl, "Could not find class ChipEventStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent"); + return nullptr; + } + jmethodID cumulativeEnergyMeasuredStructCtor = + env->GetMethodID(cumulativeEnergyMeasuredStructClass, "", "(Ljava/util/Optional;Ljava/util/Optional;)V"); + if (cumulativeEnergyMeasuredStructCtor == nullptr) + { + ChipLogError( + Zcl, + "Could not find ChipEventStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(cumulativeEnergyMeasuredStructClass, cumulativeEnergyMeasuredStructCtor, + value_energyImported, value_energyExported); + + return value; + } + case Events::PeriodicEnergyMeasured::Id: { + Events::PeriodicEnergyMeasured::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_energyImported; + if (!cppValue.energyImported.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImported); + } + else + { + jobject value_energyImportedInsideOptional; + jobject value_energyImportedInsideOptional_energy; + std::string value_energyImportedInsideOptional_energyClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_energyCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_energy = static_cast(cppValue.energyImported.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_energyClassName.c_str(), + value_energyImportedInsideOptional_energyCtorSignature.c_str(), jnivalue_energyImportedInsideOptional_energy, + value_energyImportedInsideOptional_energy); + jobject value_energyImportedInsideOptional_startTimestamp; + if (!cppValue.energyImported.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_startTimestamp); + } + else + { + jobject value_energyImportedInsideOptional_startTimestampInsideOptional; + std::string value_energyImportedInsideOptional_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_startTimestampInsideOptional = + static_cast(cppValue.energyImported.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_startTimestampInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_startTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_startTimestampInsideOptional, + value_energyImportedInsideOptional_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional( + value_energyImportedInsideOptional_startTimestampInsideOptional, + value_energyImportedInsideOptional_startTimestamp); + } + jobject value_energyImportedInsideOptional_endTimestamp; + if (!cppValue.energyImported.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_endTimestamp); + } + else + { + jobject value_energyImportedInsideOptional_endTimestampInsideOptional; + std::string value_energyImportedInsideOptional_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_endTimestampInsideOptional = + static_cast(cppValue.energyImported.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_endTimestampInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_endTimestampInsideOptional, + value_energyImportedInsideOptional_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional_endTimestampInsideOptional, + value_energyImportedInsideOptional_endTimestamp); + } + jobject value_energyImportedInsideOptional_startSystime; + if (!cppValue.energyImported.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_startSystime); + } + else + { + jobject value_energyImportedInsideOptional_startSystimeInsideOptional; + std::string value_energyImportedInsideOptional_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_startSystimeInsideOptional = + static_cast(cppValue.energyImported.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_startSystimeInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_startSystimeInsideOptional, + value_energyImportedInsideOptional_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional_startSystimeInsideOptional, + value_energyImportedInsideOptional_startSystime); + } + jobject value_energyImportedInsideOptional_endSystime; + if (!cppValue.energyImported.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyImportedInsideOptional_endSystime); + } + else + { + jobject value_energyImportedInsideOptional_endSystimeInsideOptional; + std::string value_energyImportedInsideOptional_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyImportedInsideOptional_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyImportedInsideOptional_endSystimeInsideOptional = + static_cast(cppValue.energyImported.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyImportedInsideOptional_endSystimeInsideOptionalClassName.c_str(), + value_energyImportedInsideOptional_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyImportedInsideOptional_endSystimeInsideOptional, + value_energyImportedInsideOptional_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional_endSystimeInsideOptional, + value_energyImportedInsideOptional_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value_energyImportedInsideOptional = + env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, + value_energyImportedInsideOptional_energy, value_energyImportedInsideOptional_startTimestamp, + value_energyImportedInsideOptional_endTimestamp, value_energyImportedInsideOptional_startSystime, + value_energyImportedInsideOptional_endSystime); + chip::JniReferences::GetInstance().CreateOptional(value_energyImportedInsideOptional, value_energyImported); + } + + jobject value_energyExported; + if (!cppValue.energyExported.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExported); + } + else + { + jobject value_energyExportedInsideOptional; + jobject value_energyExportedInsideOptional_energy; + std::string value_energyExportedInsideOptional_energyClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_energyCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_energy = static_cast(cppValue.energyExported.Value().energy); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_energyClassName.c_str(), + value_energyExportedInsideOptional_energyCtorSignature.c_str(), jnivalue_energyExportedInsideOptional_energy, + value_energyExportedInsideOptional_energy); + jobject value_energyExportedInsideOptional_startTimestamp; + if (!cppValue.energyExported.Value().startTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_startTimestamp); + } + else + { + jobject value_energyExportedInsideOptional_startTimestampInsideOptional; + std::string value_energyExportedInsideOptional_startTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_startTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_startTimestampInsideOptional = + static_cast(cppValue.energyExported.Value().startTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_startTimestampInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_startTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_startTimestampInsideOptional, + value_energyExportedInsideOptional_startTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional( + value_energyExportedInsideOptional_startTimestampInsideOptional, + value_energyExportedInsideOptional_startTimestamp); + } + jobject value_energyExportedInsideOptional_endTimestamp; + if (!cppValue.energyExported.Value().endTimestamp.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_endTimestamp); + } + else + { + jobject value_energyExportedInsideOptional_endTimestampInsideOptional; + std::string value_energyExportedInsideOptional_endTimestampInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_endTimestampInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_endTimestampInsideOptional = + static_cast(cppValue.energyExported.Value().endTimestamp.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_endTimestampInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_endTimestampInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_endTimestampInsideOptional, + value_energyExportedInsideOptional_endTimestampInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional_endTimestampInsideOptional, + value_energyExportedInsideOptional_endTimestamp); + } + jobject value_energyExportedInsideOptional_startSystime; + if (!cppValue.energyExported.Value().startSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_startSystime); + } + else + { + jobject value_energyExportedInsideOptional_startSystimeInsideOptional; + std::string value_energyExportedInsideOptional_startSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_startSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_startSystimeInsideOptional = + static_cast(cppValue.energyExported.Value().startSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_startSystimeInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_startSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_startSystimeInsideOptional, + value_energyExportedInsideOptional_startSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional_startSystimeInsideOptional, + value_energyExportedInsideOptional_startSystime); + } + jobject value_energyExportedInsideOptional_endSystime; + if (!cppValue.energyExported.Value().endSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_energyExportedInsideOptional_endSystime); + } + else + { + jobject value_energyExportedInsideOptional_endSystimeInsideOptional; + std::string value_energyExportedInsideOptional_endSystimeInsideOptionalClassName = "java/lang/Long"; + std::string value_energyExportedInsideOptional_endSystimeInsideOptionalCtorSignature = "(J)V"; + jlong jnivalue_energyExportedInsideOptional_endSystimeInsideOptional = + static_cast(cppValue.energyExported.Value().endSystime.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_energyExportedInsideOptional_endSystimeInsideOptionalClassName.c_str(), + value_energyExportedInsideOptional_endSystimeInsideOptionalCtorSignature.c_str(), + jnivalue_energyExportedInsideOptional_endSystimeInsideOptional, + value_energyExportedInsideOptional_endSystimeInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional_endSystimeInsideOptional, + value_energyExportedInsideOptional_endSystime); + } + + jclass energyMeasurementStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", + energyMeasurementStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct"); + return nullptr; + } + jmethodID energyMeasurementStructStructCtor_1 = env->GetMethodID( + energyMeasurementStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V"); + if (energyMeasurementStructStructCtor_1 == nullptr) + { + ChipLogError( + Zcl, "Could not find ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct constructor"); + return nullptr; + } + + value_energyExportedInsideOptional = + env->NewObject(energyMeasurementStructStructClass_1, energyMeasurementStructStructCtor_1, + value_energyExportedInsideOptional_energy, value_energyExportedInsideOptional_startTimestamp, + value_energyExportedInsideOptional_endTimestamp, value_energyExportedInsideOptional_startSystime, + value_energyExportedInsideOptional_endSystime); + chip::JniReferences::GetInstance().CreateOptional(value_energyExportedInsideOptional, value_energyExported); + } + + jclass periodicEnergyMeasuredStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent", + periodicEnergyMeasuredStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, + "Could not find class ChipEventStructs$ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent"); + return nullptr; + } + jmethodID periodicEnergyMeasuredStructCtor = + env->GetMethodID(periodicEnergyMeasuredStructClass, "", "(Ljava/util/Optional;Ljava/util/Optional;)V"); + if (periodicEnergyMeasuredStructCtor == nullptr) + { + ChipLogError( + Zcl, + "Could not find ChipEventStructs$ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(periodicEnergyMeasuredStructClass, periodicEnergyMeasuredStructCtor, + value_energyImported, value_energyExported); + + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + break; + } + break; + } case app::Clusters::DemandResponseLoadControl::Id: { using namespace app::Clusters::DemandResponseLoadControl; switch (aPath.mEventId) @@ -6701,6 +7275,48 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & using namespace app::Clusters::SampleMei; switch (aPath.mEventId) { + case Events::PingCountEvent::Id: { + Events::PingCountEvent::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_count; + std::string value_countClassName = "java/lang/Long"; + std::string value_countCtorSignature = "(J)V"; + jlong jnivalue_count = static_cast(cppValue.count); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_countClassName.c_str(), value_countCtorSignature.c_str(), jnivalue_count, value_count); + + jobject value_fabricIndex; + std::string value_fabricIndexClassName = "java/lang/Integer"; + std::string value_fabricIndexCtorSignature = "(I)V"; + jint jnivalue_fabricIndex = static_cast(cppValue.fabricIndex); + chip::JniReferences::GetInstance().CreateBoxedObject(value_fabricIndexClassName.c_str(), + value_fabricIndexCtorSignature.c_str(), jnivalue_fabricIndex, + value_fabricIndex); + + jclass pingCountEventStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$SampleMeiClusterPingCountEventEvent", pingCountEventStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$SampleMeiClusterPingCountEventEvent"); + return nullptr; + } + jmethodID pingCountEventStructCtor = + env->GetMethodID(pingCountEventStructClass, "", "(Ljava/lang/Long;Ljava/lang/Integer;)V"); + if (pingCountEventStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$SampleMeiClusterPingCountEventEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(pingCountEventStructClass, pingCountEventStructCtor, value_count, value_fabricIndex); + + return value; + } default: *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; break; diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index ee1a17cf61f369..630984be29b0a7 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -30848,6 +30848,296 @@ void CHIPValveConfigurationAndControlAttributeListAttributeCallback::CallbackFn( env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); } +CHIPElectricalEnergyMeasurementGeneratedCommandListAttributeCallback:: +CHIPElectricalEnergyMeasurementGeneratedCommandListAttributeCallback(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"); + } +} + +CHIPElectricalEnergyMeasurementGeneratedCommandListAttributeCallback::~ +CHIPElectricalEnergyMeasurementGeneratedCommandListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPElectricalEnergyMeasurementGeneratedCommandListAttributeCallback::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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPElectricalEnergyMeasurementAcceptedCommandListAttributeCallback:: +CHIPElectricalEnergyMeasurementAcceptedCommandListAttributeCallback(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"); + } +} + +CHIPElectricalEnergyMeasurementAcceptedCommandListAttributeCallback::~ +CHIPElectricalEnergyMeasurementAcceptedCommandListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPElectricalEnergyMeasurementAcceptedCommandListAttributeCallback::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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPElectricalEnergyMeasurementEventListAttributeCallback::CHIPElectricalEnergyMeasurementEventListAttributeCallback( + 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"); + } +} + +CHIPElectricalEnergyMeasurementEventListAttributeCallback::~CHIPElectricalEnergyMeasurementEventListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPElectricalEnergyMeasurementEventListAttributeCallback::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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPElectricalEnergyMeasurementAttributeListAttributeCallback::CHIPElectricalEnergyMeasurementAttributeListAttributeCallback( + 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"); + } +} + +CHIPElectricalEnergyMeasurementAttributeListAttributeCallback::~CHIPElectricalEnergyMeasurementAttributeListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPElectricalEnergyMeasurementAttributeListAttributeCallback::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"; + jlong jninewElement_0 = static_cast(entry_0); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + CHIPDemandResponseLoadControlLoadControlProgramsAttributeCallback:: CHIPDemandResponseLoadControlLoadControlProgramsAttributeCallback(jobject javaCallback, bool keepAlive) : chip::Callback::Callback(CallbackFn, this), diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 2d6857d17a4fe6..3c0191072923b8 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -88,7 +88,7 @@ using namespace chip::DeviceLayer; extern "C" { typedef void (*ConstructBytesArrayFunct)(const uint8_t * dataBuf, uint32_t dataLen); typedef void (*LogMessageFunct)(uint64_t time, uint64_t timeUS, const char * moduleName, uint8_t category, const char * msg); -typedef void (*DeviceAvailableFunc)(DeviceProxy * device, PyChipError err); +typedef void (*DeviceAvailableFunc)(chip::Controller::Python::PyObject * context, DeviceProxy * device, PyChipError err); typedef void (*ChipThreadTaskRunnerFunct)(intptr_t context); typedef void (*DeviceUnpairingCompleteFunct)(uint64_t nodeId, PyChipError error); } @@ -207,7 +207,7 @@ const char * pychip_Stack_StatusReportToString(uint32_t profileId, uint16_t stat void pychip_Stack_SetLogFunct(LogMessageFunct logFunct); PyChipError pychip_GetConnectedDeviceByNodeId(chip::Controller::DeviceCommissioner * devCtrl, chip::NodeId nodeId, - DeviceAvailableFunc callback); + chip::Controller::Python::PyObject * context, DeviceAvailableFunc callback); PyChipError pychip_FreeOperationalDeviceProxy(chip::OperationalDeviceProxy * deviceProxy); PyChipError pychip_GetLocalSessionId(chip::OperationalDeviceProxy * deviceProxy, uint16_t * localSessionId); PyChipError pychip_GetNumSessionsToPeer(chip::OperationalDeviceProxy * deviceProxy, uint32_t * numSessions); @@ -737,36 +737,37 @@ namespace { struct GetDeviceCallbacks { - GetDeviceCallbacks(DeviceAvailableFunc callback) : - mOnSuccess(OnDeviceConnectedFn, this), mOnFailure(OnConnectionFailureFn, this), mCallback(callback) + GetDeviceCallbacks(chip::Controller::Python::PyObject * context, DeviceAvailableFunc callback) : + mOnSuccess(OnDeviceConnectedFn, this), mOnFailure(OnConnectionFailureFn, this), mContext(context), mCallback(callback) {} static void OnDeviceConnectedFn(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle) { auto * self = static_cast(context); auto * operationalDeviceProxy = new OperationalDeviceProxy(&exchangeMgr, sessionHandle); - self->mCallback(operationalDeviceProxy, ToPyChipError(CHIP_NO_ERROR)); + self->mCallback(self->mContext, operationalDeviceProxy, ToPyChipError(CHIP_NO_ERROR)); delete self; } static void OnConnectionFailureFn(void * context, const ScopedNodeId & peerId, CHIP_ERROR error) { auto * self = static_cast(context); - self->mCallback(nullptr, ToPyChipError(error)); + self->mCallback(self->mContext, nullptr, ToPyChipError(error)); delete self; } Callback::Callback mOnSuccess; Callback::Callback mOnFailure; + chip::Controller::Python::PyObject * const mContext; DeviceAvailableFunc mCallback; }; } // anonymous namespace PyChipError pychip_GetConnectedDeviceByNodeId(chip::Controller::DeviceCommissioner * devCtrl, chip::NodeId nodeId, - DeviceAvailableFunc callback) + chip::Controller::Python::PyObject * context, DeviceAvailableFunc callback) { VerifyOrReturnError(devCtrl != nullptr, ToPyChipError(CHIP_ERROR_INVALID_ARGUMENT)); - auto * callbacks = new GetDeviceCallbacks(callback); + auto * callbacks = new GetDeviceCallbacks(context, callback); return ToPyChipError(devCtrl->GetConnectedDevice(nodeId, &callbacks->mOnSuccess, &callbacks->mOnFailure)); } diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 0eb22d5f81bf47..8f70c07c185fbf 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -76,7 +76,7 @@ # # CHIP_ERROR is actually signed, so using c_uint32 is weird, but everything # else seems to do it. -_DeviceAvailableFunct = CFUNCTYPE(None, c_void_p, PyChipError) +_DeviceAvailableCallbackFunct = CFUNCTYPE(None, py_object, c_void_p, PyChipError) _IssueNOCChainCallbackPythonCallbackFunct = CFUNCTYPE( None, py_object, PyChipError, c_void_p, c_size_t, c_void_p, c_size_t, c_void_p, c_size_t, c_void_p, c_size_t, c_uint64) @@ -100,6 +100,11 @@ class NOCChain: adminSubject: int +@_DeviceAvailableCallbackFunct +def _DeviceAvailableCallback(closure, device, err): + closure.deviceAvailable(device, err) + + @_IssueNOCChainCallbackPythonCallbackFunct def _IssueNOCChainCallbackPythonCallback(devCtrl, status: PyChipError, noc: c_void_p, nocLen: int, icac: c_void_p, icacLen: int, rcac: c_void_p, rcacLen: int, ipk: c_void_p, ipkLen: int, adminSubject: int): @@ -759,16 +764,6 @@ def GetConnectedDeviceSync(self, nodeid, allowPASE=True, timeoutMs: int = None): returnErr = None deviceAvailableCV = threading.Condition() - @_DeviceAvailableFunct - def DeviceAvailableCallback(device, err): - nonlocal returnDevice - nonlocal returnErr - nonlocal deviceAvailableCV - with deviceAvailableCV: - returnDevice = c_void_p(device) - returnErr = err - deviceAvailableCV.notify_all() - if allowPASE: res = self._ChipStack.Call(lambda: self._dmLib.pychip_GetDeviceBeingCommissioned( self.devCtrl, nodeid, byref(returnDevice)), timeoutMs) @@ -776,8 +771,22 @@ def DeviceAvailableCallback(device, err): print('Using PASE connection') return DeviceProxyWrapper(returnDevice) + class DeviceAvailableClosure(): + def deviceAvailable(self, device, err): + nonlocal returnDevice + nonlocal returnErr + nonlocal deviceAvailableCV + with deviceAvailableCV: + returnDevice = c_void_p(device) + returnErr = err + deviceAvailableCV.notify_all() + ctypes.pythonapi.Py_DecRef(ctypes.py_object(self)) + + closure = DeviceAvailableClosure() + ctypes.pythonapi.Py_IncRef(ctypes.py_object(closure)) self._ChipStack.Call(lambda: self._dmLib.pychip_GetConnectedDeviceByNodeId( - self.devCtrl, nodeid, DeviceAvailableCallback), timeoutMs).raise_on_error() + self.devCtrl, nodeid, ctypes.py_object(closure), _DeviceAvailableCallback), + timeoutMs).raise_on_error() # The callback might have been received synchronously (during self._ChipStack.Call()). # Check if the device is already set before waiting for the callback. @@ -1568,7 +1577,7 @@ def _InitLib(self): self._dmLib.pychip_ScriptDevicePairingDelegate_SetFabricCheckCallback.restype = PyChipError self._dmLib.pychip_GetConnectedDeviceByNodeId.argtypes = [ - c_void_p, c_uint64, _DeviceAvailableFunct] + c_void_p, c_uint64, py_object, _DeviceAvailableCallbackFunct] self._dmLib.pychip_GetConnectedDeviceByNodeId.restype = PyChipError self._dmLib.pychip_FreeOperationalDeviceProxy.argtypes = [ diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index ceaa6c58fc82fa..e6a384cd3336a9 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -6340,6 +6340,80 @@ class ChipClusters: }, }, } + _ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_INFO = { + "clusterName": "ElectricalEnergyMeasurement", + "clusterId": 0x00000091, + "commands": { + }, + "attributes": { + 0x00000000: { + "attributeName": "Accuracy", + "attributeId": 0x00000000, + "type": "", + "reportable": True, + }, + 0x00000001: { + "attributeName": "CumulativeEnergyImported", + "attributeId": 0x00000001, + "type": "", + "reportable": True, + }, + 0x00000002: { + "attributeName": "CumulativeEnergyExported", + "attributeId": 0x00000002, + "type": "", + "reportable": True, + }, + 0x00000003: { + "attributeName": "PeriodicEnergyImported", + "attributeId": 0x00000003, + "type": "", + "reportable": True, + }, + 0x00000004: { + "attributeName": "PeriodicEnergyExported", + "attributeId": 0x00000004, + "type": "", + "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, + }, + }, + } _DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_INFO = { "clusterName": "DemandResponseLoadControl", "clusterId": 0x00000096, @@ -13764,6 +13838,7 @@ class ChipClusters: 0x00000072: _ACTIVATED_CARBON_FILTER_MONITORING_CLUSTER_INFO, 0x00000080: _BOOLEAN_SENSOR_CONFIGURATION_CLUSTER_INFO, 0x00000081: _VALVE_CONFIGURATION_AND_CONTROL_CLUSTER_INFO, + 0x00000091: _ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_INFO, 0x00000096: _DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_INFO, 0x00000098: _DEVICE_ENERGY_MANAGEMENT_CLUSTER_INFO, 0x00000099: _ENERGY_EVSE_CLUSTER_INFO, @@ -13878,6 +13953,7 @@ class ChipClusters: "ActivatedCarbonFilterMonitoring": _ACTIVATED_CARBON_FILTER_MONITORING_CLUSTER_INFO, "BooleanSensorConfiguration": _BOOLEAN_SENSOR_CONFIGURATION_CLUSTER_INFO, "ValveConfigurationAndControl": _VALVE_CONFIGURATION_AND_CONTROL_CLUSTER_INFO, + "ElectricalEnergyMeasurement": _ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_INFO, "DemandResponseLoadControl": _DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_INFO, "DeviceEnergyManagement": _DEVICE_ENERGY_MANAGEMENT_CLUSTER_INFO, "EnergyEvse": _ENERGY_EVSE_CLUSTER_INFO, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 9b7b5c38555d43..a76a5978a0a820 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -22160,6 +22160,354 @@ def descriptor(cls) -> ClusterObjectDescriptor: valveFault: 'uint' = 0 +@dataclass +class ElectricalEnergyMeasurement(Cluster): + id: typing.ClassVar[int] = 0x00000091 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="accuracy", Tag=0x00000000, Type=ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct), + ClusterObjectFieldDescriptor(Label="cumulativeEnergyImported", Tag=0x00000001, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="cumulativeEnergyExported", Tag=0x00000002, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="periodicEnergyImported", Tag=0x00000003, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="periodicEnergyExported", Tag=0x00000004, Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + 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]), + ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), + ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=uint), + ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), + ]) + + accuracy: 'ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct' = None + cumulativeEnergyImported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + cumulativeEnergyExported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + periodicEnergyImported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + periodicEnergyExported: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + generatedCommandList: 'typing.List[uint]' = None + acceptedCommandList: 'typing.List[uint]' = None + eventList: 'typing.List[uint]' = None + attributeList: 'typing.List[uint]' = None + featureMap: 'uint' = None + clusterRevision: 'uint' = None + + class Enums: + class MeasurementTypeEnum(MatterIntEnum): + kUnspecified = 0x00 + kVoltage = 0x01 + kActiveCurrent = 0x02 + kReactiveCurrent = 0x03 + kApparentCurrent = 0x04 + kActivePower = 0x05 + kReactivePower = 0x06 + kApparentPower = 0x07 + kRMSVoltage = 0x08 + kRMSCurrent = 0x09 + kRMSPower = 0x0A + kFrequency = 0x0B + kPowerFactor = 0x0C + kNeutralCurrent = 0x0D + kElectricalEnergy = 0x0E + # 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 = 15, + + class Bitmaps: + class Feature(IntFlag): + kImportedEnergy = 0x1 + kExportedEnergy = 0x2 + kCumulativeEnergy = 0x4 + kPeriodicEnergy = 0x8 + + class Structs: + @dataclass + class MeasurementAccuracyRangeStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="rangeMin", Tag=0, Type=int), + ClusterObjectFieldDescriptor(Label="rangeMax", Tag=1, Type=int), + ClusterObjectFieldDescriptor(Label="percentMax", Tag=2, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="percentMin", Tag=3, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="percentTypical", Tag=4, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="fixedMax", Tag=5, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="fixedMin", Tag=6, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="fixedTypical", Tag=7, Type=typing.Optional[uint]), + ]) + + rangeMin: 'int' = 0 + rangeMax: 'int' = 0 + percentMax: 'typing.Optional[uint]' = None + percentMin: 'typing.Optional[uint]' = None + percentTypical: 'typing.Optional[uint]' = None + fixedMax: 'typing.Optional[uint]' = None + fixedMin: 'typing.Optional[uint]' = None + fixedTypical: 'typing.Optional[uint]' = None + + @dataclass + class MeasurementAccuracyStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="measurementType", Tag=0, Type=ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum), + ClusterObjectFieldDescriptor(Label="measured", Tag=1, Type=bool), + ClusterObjectFieldDescriptor(Label="minMeasuredValue", Tag=2, Type=int), + ClusterObjectFieldDescriptor(Label="maxMeasuredValue", Tag=3, Type=int), + ClusterObjectFieldDescriptor(Label="accuracyRanges", Tag=4, Type=typing.List[ElectricalEnergyMeasurement.Structs.MeasurementAccuracyRangeStruct]), + ]) + + measurementType: 'ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum' = 0 + measured: 'bool' = False + minMeasuredValue: 'int' = 0 + maxMeasuredValue: 'int' = 0 + accuracyRanges: 'typing.List[ElectricalEnergyMeasurement.Structs.MeasurementAccuracyRangeStruct]' = field(default_factory=lambda: []) + + @dataclass + class EnergyMeasurementStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="energy", Tag=0, Type=int), + ClusterObjectFieldDescriptor(Label="startTimestamp", Tag=1, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="endTimestamp", Tag=2, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="startSystime", Tag=3, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="endSystime", Tag=4, Type=typing.Optional[uint]), + ]) + + energy: 'int' = 0 + startTimestamp: 'typing.Optional[uint]' = None + endTimestamp: 'typing.Optional[uint]' = None + startSystime: 'typing.Optional[uint]' = None + endSystime: 'typing.Optional[uint]' = None + + class Attributes: + @dataclass + class Accuracy(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct) + + value: 'ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct' = field(default_factory=lambda: ElectricalEnergyMeasurement.Structs.MeasurementAccuracyStruct()) + + @dataclass + class CumulativeEnergyImported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class CumulativeEnergyExported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000002 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class PeriodicEnergyImported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000003 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class PeriodicEnergyExported(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000004 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]) + + value: 'typing.Union[None, Nullable, ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class GeneratedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF8 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AcceptedCommandList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFF9 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class EventList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFA + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class AttributeList(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFB + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[uint]) + + value: 'typing.List[uint]' = field(default_factory=lambda: []) + + @dataclass + class FeatureMap(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFC + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + @dataclass + class ClusterRevision(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000FFFD + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) + + value: 'uint' = 0 + + class Events: + @dataclass + class CumulativeEnergyMeasured(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="energyImported", Tag=0, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="energyExported", Tag=1, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ]) + + energyImported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + energyExported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass + class PeriodicEnergyMeasured(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000091 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="energyImported", Tag=0, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ClusterObjectFieldDescriptor(Label="energyExported", Tag=1, Type=typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]), + ]) + + energyImported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + energyExported: 'typing.Optional[ElectricalEnergyMeasurement.Structs.EnergyMeasurementStruct]' = None + + @dataclass class DemandResponseLoadControl(Cluster): id: typing.ClassVar[int] = 0x00000096 @@ -46871,3 +47219,25 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 + class Events: + @dataclass + class PingCountEvent(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0xFFF1FC20 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="count", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=254, Type=uint), + ]) + + count: 'uint' = 0 + fabricIndex: 'uint' = 0 + diff --git a/src/controller/tests/TestEventCaching.cpp b/src/controller/tests/TestEventCaching.cpp index df19ed4a2e92e6..f9c744f9092ad2 100644 --- a/src/controller/tests/TestEventCaching.cpp +++ b/src/controller/tests/TestEventCaching.cpp @@ -111,7 +111,8 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(testClusterAttrs) DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); diff --git a/src/controller/tests/TestEventChunking.cpp b/src/controller/tests/TestEventChunking.cpp index 005c02b0848a55..74bee0f9aab0e4 100644 --- a/src/controller/tests/TestEventChunking.cpp +++ b/src/controller/tests/TestEventChunking.cpp @@ -122,7 +122,8 @@ DECLARE_DYNAMIC_ATTRIBUTE(0x00000001, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE(0x DECLARE_DYNAMIC_ATTRIBUTE(0x00000005, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); @@ -130,7 +131,8 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(testClusterAttrsOnEndpoint4) DECLARE_DYNAMIC_ATTRIBUTE(kTestListLargeAttribute, ARRAY, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpoint4Clusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint4, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint4, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint4, testEndpoint4Clusters); diff --git a/src/controller/tests/TestEventNumberCaching.cpp b/src/controller/tests/TestEventNumberCaching.cpp index d02c7f3ffbaa1a..ee94d2800f591f 100644 --- a/src/controller/tests/TestEventNumberCaching.cpp +++ b/src/controller/tests/TestEventNumberCaching.cpp @@ -111,7 +111,8 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(testClusterAttrs) DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); diff --git a/src/controller/tests/TestReadChunking.cpp b/src/controller/tests/TestReadChunking.cpp index 3293b5027852fc..4a37a3cf37ed54 100644 --- a/src/controller/tests/TestReadChunking.cpp +++ b/src/controller/tests/TestReadChunking.cpp @@ -92,7 +92,8 @@ DECLARE_DYNAMIC_ATTRIBUTE(0x00000001, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE(0x DECLARE_DYNAMIC_ATTRIBUTE(0x00000005, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); @@ -101,7 +102,8 @@ DECLARE_DYNAMIC_ATTRIBUTE(kTestListAttribute, ARRAY, 1, 0), DECLARE_DYNAMIC_ATTR DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpoint3Clusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint3, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint3, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint3, testEndpoint3Clusters); @@ -109,7 +111,8 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(testClusterAttrsOnEndpoint4) DECLARE_DYNAMIC_ATTRIBUTE(0x00000001, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpoint4Clusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint4, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint4, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint4, testEndpoint4Clusters); @@ -119,7 +122,8 @@ DECLARE_DYNAMIC_ATTRIBUTE(0x00000001, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE(0x DECLARE_DYNAMIC_ATTRIBUTE(0x00000003, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpoint5Clusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint5, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint5, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint5, testEndpoint5Clusters); diff --git a/src/controller/tests/TestServerCommandDispatch.cpp b/src/controller/tests/TestServerCommandDispatch.cpp index 27281a0deb79f9..40b4c098ba52e6 100644 --- a/src/controller/tests/TestServerCommandDispatch.cpp +++ b/src/controller/tests/TestServerCommandDispatch.cpp @@ -215,8 +215,9 @@ constexpr CommandId testClusterCommands1[] = { kInvalidCommandId, }; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters1) -DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::UnitTesting::Id, testClusterAttrs, testClusterCommands1, nullptr), - DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), +DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), testClusterCommands1, + nullptr), + DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint1, testEndpointClusters1); @@ -225,15 +226,16 @@ constexpr CommandId testClusterCommands2[] = { kInvalidCommandId, }; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters2) -DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::UnitTesting::Id, testClusterAttrs, testClusterCommands2, nullptr), - DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), +DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), testClusterCommands2, + nullptr), + DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint2, testEndpointClusters2); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters3) -DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::UnitTesting::Id, testClusterAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), +DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::UnitTesting::Id, testClusterAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint3, testEndpointClusters3); diff --git a/src/controller/tests/TestWriteChunking.cpp b/src/controller/tests/TestWriteChunking.cpp index c65a039fe44bdd..d0555b8d2440af 100644 --- a/src/controller/tests/TestWriteChunking.cpp +++ b/src/controller/tests/TestWriteChunking.cpp @@ -83,7 +83,8 @@ DECLARE_DYNAMIC_ATTRIBUTE(kTestListAttribute, ARRAY, 1, ATTRIBUTE_MASK_WRITABLE) DECLARE_DYNAMIC_ATTRIBUTE(kTestListAttribute2, ARRAY, 1, ATTRIBUTE_MASK_WRITABLE), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h index 52399e7fd9f078..0dc1a1097ef0e7 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.h +++ b/src/darwin/Framework/CHIP/MTRDevice.h @@ -240,6 +240,90 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) { completion:(MTRDeviceOpenCommissioningWindowHandler)completion MTR_AVAILABLE(ios(17.0), macos(14.0), watchos(10.0), tvos(17.0)); +/** + * + * This set of functions allows clients to store metadata for either an entire device or for a specific endpoint. + * + * Notes: + * • Client data will be removed automatically when devices are deleted from the fabric + * • Supported client data object types are currently only: + * NSData, NSString, NSArray, NSDictionary, NSNumber + */ + +/** + * + * List of all client data types supported + * + */ +- (NSArray *)supportedClientDataClasses MTR_NEWLY_AVAILABLE; + +/** + * + * List of all client data keys stored + * + */ +- (NSArray * _Nullable)clientDataKeys MTR_NEWLY_AVAILABLE; + +/** + * + * Retrieve client metadata for a key, returns nil if no value is set + * + * @param key NSString * for the key to store the value as + */ +- (id _Nullable)clientDataForKey:(NSString *)key MTR_NEWLY_AVAILABLE; + +/** + * + * Set client metadata for a key. The value must conform to NSSecureCoding + * + * @param key NSString * for the key to store the value as + * @param value id for the value to store + */ +- (void)setClientDataForKey:(NSString *)key value:(id)value MTR_NEWLY_AVAILABLE; + +/** + * + * Remove client metadata for a key. + * + * @param key NSString * for the key to store the value as + */ +- (void)removeClientDataForKey:(NSString *)key MTR_NEWLY_AVAILABLE; + +/** + * + * List of all client data keys stored + * + */ +- (NSArray * _Nullable)clientDataKeysForEndpointID:(NSNumber *)endpointID MTR_NEWLY_AVAILABLE; + +/** + * + * Retrieve client metadata for a key, returns nil if no value is set + * + * @param key NSString * for the key to store the value as + * @param endpointID NSNumber * for the endpoint to associate the metadata with + */ +- (id _Nullable)clientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID MTR_NEWLY_AVAILABLE; + +/** + * + * Set client metadata for a key. The value must conform to NSSecureCoding. + * + * @param key NSString * for the key to store the value as. + * @param endpointID NSNumber * for the endpoint to associate the metadata with + * @param value id for the value to store + */ +- (void)setClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID value:(id)value MTR_NEWLY_AVAILABLE; + +/** + * + * Remove client metadata for a key. + * + * @param key NSString * for the key to store the value as + * @param endpointID NSNumber * for the endpoint to associate the metadata with + */ +- (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID MTR_NEWLY_AVAILABLE; + @end @protocol MTRDeviceDelegate diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 1ce1ff183457fc..116f70f5bec235 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -190,6 +190,8 @@ @interface MTRDevice () @property (nonatomic) NSDate * estimatedStartTimeFromGeneralDiagnosticsUpTime; +@property (nonatomic) NSMutableDictionary * temporaryMetaDataCache; + /** * If currentReadClient is non-null, that means that we successfully * called SendAutoResubscribeRequest on the ReadClient and have not yet gotten @@ -1725,6 +1727,86 @@ - (MTRBaseDevice *)newBaseDevice return [MTRBaseDevice deviceWithNodeID:self.nodeID controller:self.deviceController]; } +// Client Metadata Storage + +- (NSArray *)supportedClientDataClasses +{ + return @[ [NSData class], [NSString class], [NSNumber class], [NSDictionary class], [NSArray class] ]; +} + +- (NSArray * _Nullable)clientDataKeys +{ + return [self.temporaryMetaDataCache allKeys]; +} + +- (id _Nullable)clientDataForKey:(NSString *)key +{ + if (key == nil) + return nil; + + return [self.temporaryMetaDataCache objectForKey:[NSString stringWithFormat:@"%@:-1", key]]; +} + +- (void)setClientDataForKey:(NSString *)key value:(id)value +{ + // TODO: Check supported data types, and also if they conform to NSSecureCoding, when we store these + // TODO: Need to add a delegate method, so when this value changes we call back to the client + + if (key == nil || value == nil) + return; + + if (self.temporaryMetaDataCache == nil) { + self.temporaryMetaDataCache = [NSMutableDictionary dictionary]; + } + + [self.temporaryMetaDataCache setObject:value forKey:[NSString stringWithFormat:@"%@:-1", key]]; +} + +- (void)removeClientDataForKey:(NSString *)key +{ + if (key == nil) + return; + + [self.temporaryMetaDataCache removeObjectForKey:[NSString stringWithFormat:@"%@:-1", key]]; +} + +- (NSArray * _Nullable)clientDataKeysForEndpointID:(NSNumber *)endpointID +{ + if (endpointID == nil) + return nil; + // TODO: When hooked up to storage, enumerate this better + + return [self.temporaryMetaDataCache allKeys]; +} + +- (id _Nullable)clientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID +{ + if (key == nil || endpointID == nil) + return nil; + + return [self.temporaryMetaDataCache objectForKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; +} + +- (void)setClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID value:(id)value +{ + if (key == nil || value == nil || endpointID == nil) + return; + + if (self.temporaryMetaDataCache == nil) { + self.temporaryMetaDataCache = [NSMutableDictionary dictionary]; + } + + [self.temporaryMetaDataCache setObject:value forKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; +} + +- (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID +{ + if (key == nil || endpointID == nil) + return; + + [self.temporaryMetaDataCache removeObjectForKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; +} + @end @implementation MTRDevice (Deprecated) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm index 243dbc40dd5e3a..1f7d91156734b9 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm @@ -2915,6 +2915,48 @@ static BOOL AttributeIsSpecifiedInValveConfigurationAndControlCluster(AttributeI } } } +static BOOL AttributeIsSpecifiedInElectricalEnergyMeasurementCluster(AttributeId aAttributeId) +{ + using namespace Clusters::ElectricalEnergyMeasurement; + switch (aAttributeId) { + case Attributes::Accuracy::Id: { + return YES; + } + case Attributes::CumulativeEnergyImported::Id: { + return YES; + } + case Attributes::CumulativeEnergyExported::Id: { + return YES; + } + case Attributes::PeriodicEnergyImported::Id: { + return YES; + } + case Attributes::PeriodicEnergyExported::Id: { + return YES; + } + case Attributes::GeneratedCommandList::Id: { + return YES; + } + case Attributes::AcceptedCommandList::Id: { + return YES; + } + case Attributes::EventList::Id: { + return YES; + } + case Attributes::AttributeList::Id: { + return YES; + } + case Attributes::FeatureMap::Id: { + return YES; + } + case Attributes::ClusterRevision::Id: { + return YES; + } + default: { + return NO; + } + } +} static BOOL AttributeIsSpecifiedInDemandResponseLoadControlCluster(AttributeId aAttributeId) { using namespace Clusters::DemandResponseLoadControl; @@ -6306,6 +6348,9 @@ BOOL MTRAttributeIsSpecified(ClusterId aClusterId, AttributeId aAttributeId) case Clusters::ValveConfigurationAndControl::Id: { return AttributeIsSpecifiedInValveConfigurationAndControlCluster(aAttributeId); } + case Clusters::ElectricalEnergyMeasurement::Id: { + return AttributeIsSpecifiedInElectricalEnergyMeasurementCluster(aAttributeId); + } case Clusters::DemandResponseLoadControl::Id: { return AttributeIsSpecifiedInDemandResponseLoadControlCluster(aAttributeId); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 068658d831aeac..2deb87873533aa 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -7591,6 +7591,225 @@ static id _Nullable DecodeAttributeValueForValveConfigurationAndControlCluster(A *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; return nil; } +static id _Nullable DecodeAttributeValueForElectricalEnergyMeasurementCluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError) +{ + using namespace Clusters::ElectricalEnergyMeasurement; + switch (aAttributeId) { + case Attributes::Accuracy::Id: { + using TypeInfo = Attributes::Accuracy::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nonnull value; + value = [MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct new]; + value.measurementType = [NSNumber numberWithUnsignedShort:chip::to_underlying(cppValue.measurementType)]; + value.measured = [NSNumber numberWithBool:cppValue.measured]; + value.minMeasuredValue = [NSNumber numberWithLongLong:cppValue.minMeasuredValue]; + value.maxMeasuredValue = [NSNumber numberWithLongLong:cppValue.maxMeasuredValue]; + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = cppValue.accuracyRanges.begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct * newElement_1; + newElement_1 = [MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct new]; + newElement_1.rangeMin = [NSNumber numberWithLongLong:entry_1.rangeMin]; + newElement_1.rangeMax = [NSNumber numberWithLongLong:entry_1.rangeMax]; + if (entry_1.percentMax.HasValue()) { + newElement_1.percentMax = [NSNumber numberWithUnsignedShort:entry_1.percentMax.Value()]; + } else { + newElement_1.percentMax = nil; + } + if (entry_1.percentMin.HasValue()) { + newElement_1.percentMin = [NSNumber numberWithUnsignedShort:entry_1.percentMin.Value()]; + } else { + newElement_1.percentMin = nil; + } + if (entry_1.percentTypical.HasValue()) { + newElement_1.percentTypical = [NSNumber numberWithUnsignedShort:entry_1.percentTypical.Value()]; + } else { + newElement_1.percentTypical = nil; + } + if (entry_1.fixedMax.HasValue()) { + newElement_1.fixedMax = [NSNumber numberWithUnsignedLongLong:entry_1.fixedMax.Value()]; + } else { + newElement_1.fixedMax = nil; + } + if (entry_1.fixedMin.HasValue()) { + newElement_1.fixedMin = [NSNumber numberWithUnsignedLongLong:entry_1.fixedMin.Value()]; + } else { + newElement_1.fixedMin = nil; + } + if (entry_1.fixedTypical.HasValue()) { + newElement_1.fixedTypical = [NSNumber numberWithUnsignedLongLong:entry_1.fixedTypical.Value()]; + } else { + newElement_1.fixedTypical = nil; + } + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value.accuracyRanges = array_1; + } + return value; + } + case Attributes::CumulativeEnergyImported::Id: { + using TypeInfo = Attributes::CumulativeEnergyImported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + value.energy = [NSNumber numberWithLongLong:cppValue.Value().energy]; + if (cppValue.Value().startTimestamp.HasValue()) { + value.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().startTimestamp.Value()]; + } else { + value.startTimestamp = nil; + } + if (cppValue.Value().endTimestamp.HasValue()) { + value.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().endTimestamp.Value()]; + } else { + value.endTimestamp = nil; + } + if (cppValue.Value().startSystime.HasValue()) { + value.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().startSystime.Value()]; + } else { + value.startSystime = nil; + } + if (cppValue.Value().endSystime.HasValue()) { + value.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().endSystime.Value()]; + } else { + value.endSystime = nil; + } + } + return value; + } + case Attributes::CumulativeEnergyExported::Id: { + using TypeInfo = Attributes::CumulativeEnergyExported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + value.energy = [NSNumber numberWithLongLong:cppValue.Value().energy]; + if (cppValue.Value().startTimestamp.HasValue()) { + value.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().startTimestamp.Value()]; + } else { + value.startTimestamp = nil; + } + if (cppValue.Value().endTimestamp.HasValue()) { + value.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().endTimestamp.Value()]; + } else { + value.endTimestamp = nil; + } + if (cppValue.Value().startSystime.HasValue()) { + value.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().startSystime.Value()]; + } else { + value.startSystime = nil; + } + if (cppValue.Value().endSystime.HasValue()) { + value.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().endSystime.Value()]; + } else { + value.endSystime = nil; + } + } + return value; + } + case Attributes::PeriodicEnergyImported::Id: { + using TypeInfo = Attributes::PeriodicEnergyImported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + value.energy = [NSNumber numberWithLongLong:cppValue.Value().energy]; + if (cppValue.Value().startTimestamp.HasValue()) { + value.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().startTimestamp.Value()]; + } else { + value.startTimestamp = nil; + } + if (cppValue.Value().endTimestamp.HasValue()) { + value.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().endTimestamp.Value()]; + } else { + value.endTimestamp = nil; + } + if (cppValue.Value().startSystime.HasValue()) { + value.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().startSystime.Value()]; + } else { + value.startSystime = nil; + } + if (cppValue.Value().endSystime.HasValue()) { + value.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().endSystime.Value()]; + } else { + value.endSystime = nil; + } + } + return value; + } + case Attributes::PeriodicEnergyExported::Id: { + using TypeInfo = Attributes::PeriodicEnergyExported::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + value.energy = [NSNumber numberWithLongLong:cppValue.Value().energy]; + if (cppValue.Value().startTimestamp.HasValue()) { + value.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().startTimestamp.Value()]; + } else { + value.startTimestamp = nil; + } + if (cppValue.Value().endTimestamp.HasValue()) { + value.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.Value().endTimestamp.Value()]; + } else { + value.endTimestamp = nil; + } + if (cppValue.Value().startSystime.HasValue()) { + value.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().startSystime.Value()]; + } else { + value.startSystime = nil; + } + if (cppValue.Value().endSystime.HasValue()) { + value.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.Value().endSystime.Value()]; + } else { + value.endSystime = nil; + } + } + return value; + } + default: { + break; + } + } + + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + return nil; +} static id _Nullable DecodeAttributeValueForDemandResponseLoadControlCluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError) { using namespace Clusters::DemandResponseLoadControl; @@ -17679,6 +17898,9 @@ id _Nullable MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::T case Clusters::ValveConfigurationAndControl::Id: { return DecodeAttributeValueForValveConfigurationAndControlCluster(aPath.mAttributeId, aReader, aError); } + case Clusters::ElectricalEnergyMeasurement::Id: { + return DecodeAttributeValueForElectricalEnergyMeasurementCluster(aPath.mAttributeId, aReader, aError); + } case Clusters::DemandResponseLoadControl::Id: { return DecodeAttributeValueForDemandResponseLoadControlCluster(aPath.mAttributeId, aReader, aError); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 1db156e4c1428c..ad4120b06c3ee5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -7228,6 +7228,97 @@ MTR_PROVISIONALLY_AVAILABLE @end +/** + * Cluster Electrical Energy Measurement + * + * This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. + */ +MTR_PROVISIONALLY_AVAILABLE +@interface MTRBaseClusterElectricalEnergyMeasurement : MTRGenericBaseCluster + +- (void)readAttributeAccuracyWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAccuracyWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAccuracyWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeCumulativeEnergyImportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeCumulativeEnergyImportedWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeCumulativeEnergyImportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeCumulativeEnergyExportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeCumulativeEnergyExportedWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeCumulativeEnergyExportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributePeriodicEnergyImportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributePeriodicEnergyImportedWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributePeriodicEnergyImportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributePeriodicEnergyExportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributePeriodicEnergyExportedWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributePeriodicEnergyExportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +@interface MTRBaseClusterElectricalEnergyMeasurement (Availability) + +/** + * For all instance methods (reads, writes, commands) that take a completion, + * the completion will be called on the provided queue. + */ +- (instancetype _Nullable)initWithDevice:(MTRBaseDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue MTR_PROVISIONALLY_AVAILABLE; + +@end + /** * Cluster Demand Response Load Control * @@ -16754,6 +16845,31 @@ typedef NS_OPTIONS(uint16_t, MTRValveConfigurationAndControlValveFaultBitmap) { MTRValveConfigurationAndControlValveFaultBitmapLeaking MTR_PROVISIONALLY_AVAILABLE = 0x4, } MTR_PROVISIONALLY_AVAILABLE; +typedef NS_ENUM(uint16_t, MTRElectricalEnergyMeasurementMeasurementType) { + MTRElectricalEnergyMeasurementMeasurementTypeUnspecified MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRElectricalEnergyMeasurementMeasurementTypeVoltage MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRElectricalEnergyMeasurementMeasurementTypeActiveCurrent MTR_PROVISIONALLY_AVAILABLE = 0x02, + MTRElectricalEnergyMeasurementMeasurementTypeReactiveCurrent MTR_PROVISIONALLY_AVAILABLE = 0x03, + MTRElectricalEnergyMeasurementMeasurementTypeApparentCurrent MTR_PROVISIONALLY_AVAILABLE = 0x04, + MTRElectricalEnergyMeasurementMeasurementTypeActivePower MTR_PROVISIONALLY_AVAILABLE = 0x05, + MTRElectricalEnergyMeasurementMeasurementTypeReactivePower MTR_PROVISIONALLY_AVAILABLE = 0x06, + MTRElectricalEnergyMeasurementMeasurementTypeApparentPower MTR_PROVISIONALLY_AVAILABLE = 0x07, + MTRElectricalEnergyMeasurementMeasurementTypeRMSVoltage MTR_PROVISIONALLY_AVAILABLE = 0x08, + MTRElectricalEnergyMeasurementMeasurementTypeRMSCurrent MTR_PROVISIONALLY_AVAILABLE = 0x09, + MTRElectricalEnergyMeasurementMeasurementTypeRMSPower MTR_PROVISIONALLY_AVAILABLE = 0x0A, + MTRElectricalEnergyMeasurementMeasurementTypeFrequency MTR_PROVISIONALLY_AVAILABLE = 0x0B, + MTRElectricalEnergyMeasurementMeasurementTypePowerFactor MTR_PROVISIONALLY_AVAILABLE = 0x0C, + MTRElectricalEnergyMeasurementMeasurementTypeNeutralCurrent MTR_PROVISIONALLY_AVAILABLE = 0x0D, + MTRElectricalEnergyMeasurementMeasurementTypeElectricalEnergy MTR_PROVISIONALLY_AVAILABLE = 0x0E, +} MTR_PROVISIONALLY_AVAILABLE; + +typedef NS_OPTIONS(uint32_t, MTRElectricalEnergyMeasurementFeature) { + MTRElectricalEnergyMeasurementFeatureImportedEnergy MTR_PROVISIONALLY_AVAILABLE = 0x1, + MTRElectricalEnergyMeasurementFeatureExportedEnergy MTR_PROVISIONALLY_AVAILABLE = 0x2, + MTRElectricalEnergyMeasurementFeatureCumulativeEnergy MTR_PROVISIONALLY_AVAILABLE = 0x4, + MTRElectricalEnergyMeasurementFeaturePeriodicEnergy MTR_PROVISIONALLY_AVAILABLE = 0x8, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTRDemandResponseLoadControlCriticalityLevel) { MTRDemandResponseLoadControlCriticalityLevelUnknown MTR_PROVISIONALLY_AVAILABLE = 0x00, MTRDemandResponseLoadControlCriticalityLevelGreen MTR_PROVISIONALLY_AVAILABLE = 0x01, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 447b836708be5c..45c8b38f7a85dc 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -50278,6 +50278,406 @@ + (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheC @end +@implementation MTRBaseClusterElectricalEnergyMeasurement + +- (void)readAttributeAccuracyWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::Accuracy::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAccuracyWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::Accuracy::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAccuracyWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::Accuracy::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeCumulativeEnergyImportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyImported::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeCumulativeEnergyImportedWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyImported::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeCumulativeEnergyImportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyImported::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeCumulativeEnergyExportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyExported::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeCumulativeEnergyExportedWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyExported::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeCumulativeEnergyExportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::CumulativeEnergyExported::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributePeriodicEnergyImportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::PeriodicEnergyImported::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributePeriodicEnergyImportedWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::PeriodicEnergyImported::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributePeriodicEnergyImportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::PeriodicEnergyImported::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributePeriodicEnergyExportedWithCompletion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::PeriodicEnergyExported::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributePeriodicEnergyExportedWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::PeriodicEnergyExported::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributePeriodicEnergyExportedWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::PeriodicEnergyExported::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::AcceptedCommandList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::AcceptedCommandList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::AcceptedCommandList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::EventList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::EventList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::EventList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::AttributeList::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::AttributeList::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::AttributeList::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::FeatureMap::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::FeatureMap::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::FeatureMap::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::ClusterRevision::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::ClusterRevision::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = ElectricalEnergyMeasurement::Attributes::ClusterRevision::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +@end + @implementation MTRBaseClusterDemandResponseLoadControl - (void)registerLoadControlProgramRequestWithParams:(MTRDemandResponseLoadControlClusterRegisterLoadControlProgramRequestParams *)params completion:(MTRStatusCompletion)completion diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 0907ddf7c3bb0d..6d66edeb9fbdff 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -150,6 +150,7 @@ typedef NS_ENUM(uint32_t, MTRClusterIDType) { MTRClusterIDTypeActivatedCarbonFilterMonitoringID MTR_PROVISIONALLY_AVAILABLE = 0x00000072, MTRClusterIDTypeBooleanSensorConfigurationID MTR_PROVISIONALLY_AVAILABLE = 0x00000080, MTRClusterIDTypeValveConfigurationAndControlID MTR_PROVISIONALLY_AVAILABLE = 0x00000081, + MTRClusterIDTypeElectricalEnergyMeasurementID MTR_PROVISIONALLY_AVAILABLE = 0x00000091, MTRClusterIDTypeDemandResponseLoadControlID MTR_PROVISIONALLY_AVAILABLE = 0x00000096, MTRClusterIDTypeDeviceEnergyManagementID MTR_PROVISIONALLY_AVAILABLE = 0x00000098, MTRClusterIDTypeEnergyEVSEID MTR_PROVISIONALLY_AVAILABLE = 0x00000099, @@ -2605,6 +2606,19 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeFeatureMapID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeFeatureMapID, MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeClusterRevisionID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + // Cluster ElectricalEnergyMeasurement attributes + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAccuracyID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyImportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyExportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000002, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyImportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000003, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyExportedID MTR_PROVISIONALLY_AVAILABLE = 0x00000004, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeGeneratedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAcceptedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAttributeListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAttributeListID, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeFeatureMapID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeFeatureMapID, + MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeClusterRevisionID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeClusterRevisionID, + // Cluster DemandResponseLoadControl attributes MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeLoadControlProgramsID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfLoadControlProgramsID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, @@ -7138,6 +7152,10 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { MTREventIDTypeClusterValveConfigurationAndControlEventValveStateChangedID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, MTREventIDTypeClusterValveConfigurationAndControlEventValveFaultID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, + // Cluster ElectricalEnergyMeasurement events + MTREventIDTypeClusterElectricalEnergyMeasurementEventCumulativeEnergyMeasuredID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + MTREventIDTypeClusterElectricalEnergyMeasurementEventPeriodicEnergyMeasuredID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, + // Cluster DemandResponseLoadControl events MTREventIDTypeClusterDemandResponseLoadControlEventLoadControlEventStatusChangeID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, @@ -7281,4 +7299,7 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { MTREventIDTypeClusterUnitTestingEventTestEventID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000001, MTREventIDTypeClusterUnitTestingEventTestFabricScopedEventID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, + // Cluster SampleMEI events + MTREventIDTypeClusterSampleMEIEventPingCountEventID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + }; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index 8e2ff98413a206..12e03cd11b4e27 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -3428,6 +3428,52 @@ MTR_PROVISIONALLY_AVAILABLE @end +/** + * Cluster Electrical Energy Measurement + * This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. + */ +MTR_PROVISIONALLY_AVAILABLE +@interface MTRClusterElectricalEnergyMeasurement : MTRGenericCluster + +- (NSDictionary * _Nullable)readAttributeAccuracyWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeCumulativeEnergyImportedWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeCumulativeEnergyExportedWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributePeriodicEnergyImportedWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributePeriodicEnergyExportedWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +@interface MTRClusterElectricalEnergyMeasurement (Availability) + +/** + * The queue is currently unused, but may be used in the future for calling completions + * for command invocations if commands are added to this cluster. + */ +- (instancetype _Nullable)initWithDevice:(MTRDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue MTR_PROVISIONALLY_AVAILABLE; + +@end + /** * Cluster Demand Response Load Control * This cluster provides an interface to the functionality of Smart Energy Demand Response and Load Control. diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 6a24ca9281c63c..fbf736a5882e3e 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -9253,6 +9253,65 @@ - (void)writeAttributeOpenLevelWithValue:(NSDictionary *)dataVal @end +@implementation MTRClusterElectricalEnergyMeasurement + +- (NSDictionary * _Nullable)readAttributeAccuracyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAccuracyID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeCumulativeEnergyImportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyImportedID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeCumulativeEnergyExportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyExportedID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributePeriodicEnergyImportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyImportedID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributePeriodicEnergyExportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyExportedID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeGeneratedCommandListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAcceptedCommandListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeEventListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAttributeListID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeFeatureMapID) params:params]; +} + +- (NSDictionary * _Nullable)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeElectricalEnergyMeasurementID) attributeID:@(MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeClusterRevisionID) params:params]; +} + +@end + @implementation MTRClusterDemandResponseLoadControl - (void)registerLoadControlProgramRequestWithParams:(MTRDemandResponseLoadControlClusterRegisterLoadControlProgramRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(MTRStatusCompletion)completion diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm index d9ac43efc72db2..a3dbd7d0369423 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm @@ -590,6 +590,15 @@ static BOOL CommandNeedsTimedInvokeInValveConfigurationAndControlCluster(Attribu } } } +static BOOL CommandNeedsTimedInvokeInElectricalEnergyMeasurementCluster(AttributeId aAttributeId) +{ + using namespace Clusters::ElectricalEnergyMeasurement; + switch (aAttributeId) { + default: { + return NO; + } + } +} static BOOL CommandNeedsTimedInvokeInDemandResponseLoadControlCluster(AttributeId aAttributeId) { using namespace Clusters::DemandResponseLoadControl; @@ -1245,6 +1254,9 @@ BOOL MTRCommandNeedsTimedInvoke(NSNumber * _Nonnull aClusterID, NSNumber * _Nonn case Clusters::ValveConfigurationAndControl::Id: { return CommandNeedsTimedInvokeInValveConfigurationAndControlCluster(commandID); } + case Clusters::ElectricalEnergyMeasurement::Id: { + return CommandNeedsTimedInvokeInElectricalEnergyMeasurementCluster(commandID); + } case Clusters::DemandResponseLoadControl::Id: { return CommandNeedsTimedInvokeInDemandResponseLoadControlCluster(commandID); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 5912d3d8d6454e..c9a38080b463dc 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -2461,6 +2461,162 @@ static id _Nullable DecodeEventPayloadForValveConfigurationAndControlCluster(Eve *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; return nil; } +static id _Nullable DecodeEventPayloadForElectricalEnergyMeasurementCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError) +{ + using namespace Clusters::ElectricalEnergyMeasurement; + switch (aEventId) { + case Events::CumulativeEnergyMeasured::Id: { + Events::CumulativeEnergyMeasured::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent new]; + + do { + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable memberValue; + if (cppValue.energyImported.HasValue()) { + memberValue = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + memberValue.energy = [NSNumber numberWithLongLong:cppValue.energyImported.Value().energy]; + if (cppValue.energyImported.Value().startTimestamp.HasValue()) { + memberValue.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyImported.Value().startTimestamp.Value()]; + } else { + memberValue.startTimestamp = nil; + } + if (cppValue.energyImported.Value().endTimestamp.HasValue()) { + memberValue.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyImported.Value().endTimestamp.Value()]; + } else { + memberValue.endTimestamp = nil; + } + if (cppValue.energyImported.Value().startSystime.HasValue()) { + memberValue.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyImported.Value().startSystime.Value()]; + } else { + memberValue.startSystime = nil; + } + if (cppValue.energyImported.Value().endSystime.HasValue()) { + memberValue.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyImported.Value().endSystime.Value()]; + } else { + memberValue.endSystime = nil; + } + } else { + memberValue = nil; + } + value.energyImported = memberValue; + } while (0); + do { + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable memberValue; + if (cppValue.energyExported.HasValue()) { + memberValue = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + memberValue.energy = [NSNumber numberWithLongLong:cppValue.energyExported.Value().energy]; + if (cppValue.energyExported.Value().startTimestamp.HasValue()) { + memberValue.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyExported.Value().startTimestamp.Value()]; + } else { + memberValue.startTimestamp = nil; + } + if (cppValue.energyExported.Value().endTimestamp.HasValue()) { + memberValue.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyExported.Value().endTimestamp.Value()]; + } else { + memberValue.endTimestamp = nil; + } + if (cppValue.energyExported.Value().startSystime.HasValue()) { + memberValue.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyExported.Value().startSystime.Value()]; + } else { + memberValue.startSystime = nil; + } + if (cppValue.energyExported.Value().endSystime.HasValue()) { + memberValue.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyExported.Value().endSystime.Value()]; + } else { + memberValue.endSystime = nil; + } + } else { + memberValue = nil; + } + value.energyExported = memberValue; + } while (0); + + return value; + } + case Events::PeriodicEnergyMeasured::Id: { + Events::PeriodicEnergyMeasured::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent new]; + + do { + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable memberValue; + if (cppValue.energyImported.HasValue()) { + memberValue = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + memberValue.energy = [NSNumber numberWithLongLong:cppValue.energyImported.Value().energy]; + if (cppValue.energyImported.Value().startTimestamp.HasValue()) { + memberValue.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyImported.Value().startTimestamp.Value()]; + } else { + memberValue.startTimestamp = nil; + } + if (cppValue.energyImported.Value().endTimestamp.HasValue()) { + memberValue.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyImported.Value().endTimestamp.Value()]; + } else { + memberValue.endTimestamp = nil; + } + if (cppValue.energyImported.Value().startSystime.HasValue()) { + memberValue.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyImported.Value().startSystime.Value()]; + } else { + memberValue.startSystime = nil; + } + if (cppValue.energyImported.Value().endSystime.HasValue()) { + memberValue.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyImported.Value().endSystime.Value()]; + } else { + memberValue.endSystime = nil; + } + } else { + memberValue = nil; + } + value.energyImported = memberValue; + } while (0); + do { + MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable memberValue; + if (cppValue.energyExported.HasValue()) { + memberValue = [MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct new]; + memberValue.energy = [NSNumber numberWithLongLong:cppValue.energyExported.Value().energy]; + if (cppValue.energyExported.Value().startTimestamp.HasValue()) { + memberValue.startTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyExported.Value().startTimestamp.Value()]; + } else { + memberValue.startTimestamp = nil; + } + if (cppValue.energyExported.Value().endTimestamp.HasValue()) { + memberValue.endTimestamp = [NSNumber numberWithUnsignedInt:cppValue.energyExported.Value().endTimestamp.Value()]; + } else { + memberValue.endTimestamp = nil; + } + if (cppValue.energyExported.Value().startSystime.HasValue()) { + memberValue.startSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyExported.Value().startSystime.Value()]; + } else { + memberValue.startSystime = nil; + } + if (cppValue.energyExported.Value().endSystime.HasValue()) { + memberValue.endSystime = [NSNumber numberWithUnsignedLongLong:cppValue.energyExported.Value().endSystime.Value()]; + } else { + memberValue.endSystime = nil; + } + } else { + memberValue = nil; + } + value.energyExported = memberValue; + } while (0); + + return value; + } + default: { + break; + } + } + + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + return nil; +} static id _Nullable DecodeEventPayloadForDemandResponseLoadControlCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError) { using namespace Clusters::DemandResponseLoadControl; @@ -4075,6 +4231,28 @@ static id _Nullable DecodeEventPayloadForSampleMEICluster(EventId aEventId, TLV: { using namespace Clusters::SampleMei; switch (aEventId) { + case Events::PingCountEvent::Id: { + Events::PingCountEvent::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRSampleMEIClusterPingCountEventEvent new]; + + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithUnsignedInt:cppValue.count]; + value.count = memberValue; + } while (0); + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithUnsignedChar:cppValue.fabricIndex]; + value.fabricIndex = memberValue; + } while (0); + + return value; + } default: { break; } @@ -4273,6 +4451,9 @@ id _Nullable MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVRead case Clusters::ValveConfigurationAndControl::Id: { return DecodeEventPayloadForValveConfigurationAndControlCluster(aPath.mEventId, aReader, aError); } + case Clusters::ElectricalEnergyMeasurement::Id: { + return DecodeEventPayloadForElectricalEnergyMeasurementCluster(aPath.mEventId, aReader, aError); + } case Clusters::DemandResponseLoadControl::Id: { return DecodeEventPayloadForDemandResponseLoadControlCluster(aPath.mEventId, aReader, aError); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index 65a361cf605a95..6242c7e9460229 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1072,6 +1072,48 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nonnull valveFault MTR_PROVISIONALLY_AVAILABLE; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull rangeMin MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull rangeMax MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable percentMax MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable percentMin MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable percentTypical MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable fixedMax MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable fixedMin MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable fixedTypical MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull measurementType MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull measured MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull minMeasuredValue MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull maxMeasuredValue MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSArray * _Nonnull accuracyRanges MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull energy MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable startTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable endTimestamp MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable startSystime MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable endSystime MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent : NSObject +@property (nonatomic, copy) MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable energyImported MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable energyExported MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent : NSObject +@property (nonatomic, copy) MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable energyImported MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable energyExported MTR_PROVISIONALLY_AVAILABLE; +@end + MTR_PROVISIONALLY_AVAILABLE @interface MTRDemandResponseLoadControlClusterHeatingSourceControlStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull heatingSource MTR_PROVISIONALLY_AVAILABLE; @@ -1919,4 +1961,10 @@ MTR_DEPRECATED("Please use MTRUnitTestingClusterTestFabricScopedEventEvent", ios @property (nonatomic, copy) NSNumber * _Nonnull fabricIndex MTR_DEPRECATED("Please use MTRUnitTestingClusterTestFabricScopedEventEvent", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRSampleMEIClusterPingCountEventEvent : NSObject +@property (nonatomic, copy, getter=getCount) NSNumber * _Nonnull count MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull fabricIndex MTR_PROVISIONALLY_AVAILABLE; +@end + NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 1262d5d534593a..06be97e69ee61b 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -4310,6 +4310,192 @@ - (NSString *)description @end +@implementation MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct +- (instancetype)init +{ + if (self = [super init]) { + + _rangeMin = @(0); + + _rangeMax = @(0); + + _percentMax = nil; + + _percentMin = nil; + + _percentTypical = nil; + + _fixedMax = nil; + + _fixedMin = nil; + + _fixedTypical = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct alloc] init]; + + other.rangeMin = self.rangeMin; + other.rangeMax = self.rangeMax; + other.percentMax = self.percentMax; + other.percentMin = self.percentMin; + other.percentTypical = self.percentTypical; + other.fixedMax = self.fixedMax; + other.fixedMin = self.fixedMin; + other.fixedTypical = self.fixedTypical; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: rangeMin:%@; rangeMax:%@; percentMax:%@; percentMin:%@; percentTypical:%@; fixedMax:%@; fixedMin:%@; fixedTypical:%@; >", NSStringFromClass([self class]), _rangeMin, _rangeMax, _percentMax, _percentMin, _percentTypical, _fixedMax, _fixedMin, _fixedTypical]; + return descriptionString; +} + +@end + +@implementation MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct +- (instancetype)init +{ + if (self = [super init]) { + + _measurementType = @(0); + + _measured = @(0); + + _minMeasuredValue = @(0); + + _maxMeasuredValue = @(0); + + _accuracyRanges = [NSArray array]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct alloc] init]; + + other.measurementType = self.measurementType; + other.measured = self.measured; + other.minMeasuredValue = self.minMeasuredValue; + other.maxMeasuredValue = self.maxMeasuredValue; + other.accuracyRanges = self.accuracyRanges; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: measurementType:%@; measured:%@; minMeasuredValue:%@; maxMeasuredValue:%@; accuracyRanges:%@; >", NSStringFromClass([self class]), _measurementType, _measured, _minMeasuredValue, _maxMeasuredValue, _accuracyRanges]; + return descriptionString; +} + +@end + +@implementation MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct +- (instancetype)init +{ + if (self = [super init]) { + + _energy = @(0); + + _startTimestamp = nil; + + _endTimestamp = nil; + + _startSystime = nil; + + _endSystime = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct alloc] init]; + + other.energy = self.energy; + other.startTimestamp = self.startTimestamp; + other.endTimestamp = self.endTimestamp; + other.startSystime = self.startSystime; + other.endSystime = self.endSystime; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: energy:%@; startTimestamp:%@; endTimestamp:%@; startSystime:%@; endSystime:%@; >", NSStringFromClass([self class]), _energy, _startTimestamp, _endTimestamp, _startSystime, _endSystime]; + return descriptionString; +} + +@end + +@implementation MTRElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent +- (instancetype)init +{ + if (self = [super init]) { + + _energyImported = nil; + + _energyExported = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent alloc] init]; + + other.energyImported = self.energyImported; + other.energyExported = self.energyExported; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: energyImported:%@; energyExported:%@; >", NSStringFromClass([self class]), _energyImported, _energyExported]; + return descriptionString; +} + +@end + +@implementation MTRElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent +- (instancetype)init +{ + if (self = [super init]) { + + _energyImported = nil; + + _energyExported = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent alloc] init]; + + other.energyImported = self.energyImported; + other.energyExported = self.energyExported; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: energyImported:%@; energyExported:%@; >", NSStringFromClass([self class]), _energyImported, _energyExported]; + return descriptionString; +} + +@end + @implementation MTRDemandResponseLoadControlClusterHeatingSourceControlStruct - (instancetype)init { @@ -7515,4 +7701,34 @@ @implementation MTRTestClusterClusterTestFabricScopedEventEvent : MTRUnitTesting @dynamic fabricIndex; @end +@implementation MTRSampleMEIClusterPingCountEventEvent +- (instancetype)init +{ + if (self = [super init]) { + + _count = @(0); + + _fabricIndex = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRSampleMEIClusterPingCountEventEvent alloc] init]; + + other.count = self.count; + other.fabricIndex = self.fabricIndex; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: count:%@; fabricIndex:%@; >", NSStringFromClass([self class]), _count, _fabricIndex]; + return descriptionString; +} + +@end + NS_ASSUME_NONNULL_END diff --git a/src/platform/Linux/SystemPlatformConfig.h b/src/platform/Linux/SystemPlatformConfig.h index 8edc16c1c00307..21495f93a38b82 100644 --- a/src/platform/Linux/SystemPlatformConfig.h +++ b/src/platform/Linux/SystemPlatformConfig.h @@ -41,3 +41,4 @@ struct ChipDeviceEvent; #define CHIP_SYSTEM_CONFIG_POOL_USE_HEAP 1 // ========== Platform-specific Configuration Overrides ========= +#define CHIP_CONFIG_MDNS_RESOLVE_LOOKUP_RESULTS 5 diff --git a/src/platform/Tizen/CHIPDevicePlatformConfig.h b/src/platform/Tizen/CHIPDevicePlatformConfig.h index 110f383e16f6d1..27d9d5709fa831 100644 --- a/src/platform/Tizen/CHIPDevicePlatformConfig.h +++ b/src/platform/Tizen/CHIPDevicePlatformConfig.h @@ -38,12 +38,14 @@ #define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1 -#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 #else #define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 0 -#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 0 +#endif + +#ifndef CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 #endif #ifndef CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/cc13xx_26xx/cc13x2_26x2/BUILD.gn b/src/platform/cc13xx_26xx/cc13x2_26x2/BUILD.gn index c86b77ec45f4eb..ff746181a7f632 100644 --- a/src/platform/cc13xx_26xx/cc13x2_26x2/BUILD.gn +++ b/src/platform/cc13xx_26xx/cc13x2_26x2/BUILD.gn @@ -65,8 +65,7 @@ static_library("cc13x2_26x2") { # this needs to be in the final link to place the data correctly # see ${chip_root}/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni #"oad_image_header.c", - "../OTAImageProcessorImpl.cpp", - "../OTAImageProcessorImpl.h", + "OTAImageProcessorImpl.cpp", ] } diff --git a/src/platform/cc13xx_26xx/OTAImageProcessorImpl.cpp b/src/platform/cc13xx_26xx/cc13x2_26x2/OTAImageProcessorImpl.cpp similarity index 100% rename from src/platform/cc13xx_26xx/OTAImageProcessorImpl.cpp rename to src/platform/cc13xx_26xx/cc13x2_26x2/OTAImageProcessorImpl.cpp diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/BUILD.gn b/src/platform/cc13xx_26xx/cc13x4_26x4/BUILD.gn index 18298ed0ce5841..414e7b1d78bcdc 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/BUILD.gn +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/BUILD.gn @@ -61,13 +61,7 @@ static_library("cc13x4_26x4") { } if (chip_enable_ota_requestor) { - sources += [ - # this needs to be in the final link to place the data correctly - # see ${chip_root}/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni - #"oad_image_header.c", - "../OTAImageProcessorImpl.cpp", - "../OTAImageProcessorImpl.h", - ] + sources += [ "OTAImageProcessorImpl.cpp" ] } if (chip_enable_openthread) { diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/OTAImageProcessorImpl.cpp b/src/platform/cc13xx_26xx/cc13x4_26x4/OTAImageProcessorImpl.cpp new file mode 100644 index 00000000000000..94e5a2295aaaf7 --- /dev/null +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/OTAImageProcessorImpl.cpp @@ -0,0 +1,391 @@ +/* + * + * Copyright (c) 2021 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 +#include + +#include "OTAImageProcessorImpl.h" + +#include + +#include "inttypes.h" + +// clang-format off +/* driverlib header for resetting the SoC */ +#include +#include DeviceFamily_constructPath(driverlib/sys_ctrl.h) +// clang-format on + +using namespace chip::DeviceLayer; +using namespace chip::DeviceLayer::PersistedStorage; + +uint64_t totalBytesWrittenNvs = 0; + +#define MATTER_OTA_HEADER_MAGIC_NUMBER_LENGTH 4 +#define MATTER_OTA_HEADER_IMG_LENGTH_BYTES 4 +#define MATTER_OTA_HEADER_PADDING 4 +#define MATTER_OTA_HEADER_LENGTH_BYTES 4 + +namespace chip { + +CHIP_ERROR OTAImageProcessorImpl::PrepareDownload() +{ + PlatformMgr().ScheduleWork(HandlePrepareDownload, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Finalize() +{ + PlatformMgr().ScheduleWork(HandleFinalize, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Apply() +{ + PlatformMgr().ScheduleWork(HandleApply, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Abort() +{ + PlatformMgr().ScheduleWork(HandleAbort, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) +{ + if (nullptr == mNvsHandle) + { + return CHIP_ERROR_INTERNAL; + } + + if ((nullptr == block.data()) || block.empty()) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + + // Store block data for HandleProcessBlock to access + CHIP_ERROR err = SetBlock(block); + if (err != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Cannot set block data: %" CHIP_ERROR_FORMAT, err.Format()); + } + + PlatformMgr().ScheduleWork(HandleProcessBlock, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +bool OTAImageProcessorImpl::IsFirstImageRun() +{ + OTARequestorInterface * requestor; + uint32_t runningSwVer; + + if (CHIP_NO_ERROR != ConfigurationMgr().GetSoftwareVersion(runningSwVer)) + { + return false; + } + + requestor = GetRequestorInstance(); + + return (requestor->GetTargetVersion() == runningSwVer) && + (requestor->GetCurrentUpdateState() == chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying); +} + +/* makes room for the new block if needed */ +static bool writeExtFlashImgPages(NVS_Handle handle, ssize_t offset, MutableByteSpan block) +{ + int_fast16_t status; + NVS_Attrs regionAttrs; + unsigned int erasedSectors; + unsigned int neededSectors; + size_t sectorSize; + size_t imageOffset; + uint8_t * data; + size_t dataSize; + + if (offset < 0) + { + size_t blockOffset = -offset; + if (blockOffset >= block.size()) + { + /* We have not downloaded past the Matter OTA header */ + return true; + } + + imageOffset = 0; + data = block.data() + blockOffset; + dataSize = block.size() - blockOffset; + } + else + { + imageOffset = offset; + data = block.data(); + dataSize = block.size(); + } + + NVS_getAttrs(handle, ®ionAttrs); + sectorSize = regionAttrs.sectorSize; + erasedSectors = (imageOffset + (sectorSize - 1)) / sectorSize; + neededSectors = ((imageOffset + dataSize) + (sectorSize - 1)) / sectorSize; + if (neededSectors != erasedSectors) + { + status = NVS_erase(handle, (erasedSectors * sectorSize), (neededSectors - erasedSectors) * sectorSize); + if (status != NVS_STATUS_SUCCESS) + { + ChipLogError(SoftwareUpdate, "NVS_erase failed status: %d", status); + return false; + } + } + status = NVS_write(handle, imageOffset, data, dataSize, NVS_WRITE_POST_VERIFY); + if (status != NVS_STATUS_SUCCESS) + { + ChipLogError(SoftwareUpdate, "NVS_write failed status: %d", status); + return false; + } + else + { + totalBytesWrittenNvs += dataSize; + ChipLogProgress(SoftwareUpdate, "Total written bytes: %d", (size_t) totalBytesWrittenNvs); + } + return true; +} + +/* Erase the MCUBoot slot */ +#define BOOT_SLOT_SIZE (0x000F6000) /* must match flash_map_backend */ +static bool eraseExtSlot(NVS_Handle handle) +{ + int_fast16_t status; + NVS_Attrs regionAttrs; + unsigned int sectors; + + NVS_getAttrs(handle, ®ionAttrs); + /* calculate the number of sectors to erase */ + sectors = (BOOT_SLOT_SIZE + (regionAttrs.sectorSize - 1)) / regionAttrs.sectorSize; + status = NVS_erase(handle, 0U, sectors * regionAttrs.sectorSize); + + return (status == NVS_STATUS_SUCCESS); +} + +/* Erase the MCUBoot header to ensure the image isn't applied */ +#define BOOT_HEADER_SIZE (0x80) +static bool eraseExtHeader(NVS_Handle handle) +{ + int_fast16_t status; + NVS_Attrs regionAttrs; + unsigned int sectors; + + NVS_getAttrs(handle, ®ionAttrs); + /* calculate the number of sectors to erase */ + sectors = (BOOT_HEADER_SIZE + (regionAttrs.sectorSize - 1)) / regionAttrs.sectorSize; + status = NVS_erase(handle, 0U, sectors * regionAttrs.sectorSize); + + return (status == NVS_STATUS_SUCCESS); +} + +CHIP_ERROR OTAImageProcessorImpl::ConfirmCurrentImage() +{ + return CHIP_NO_ERROR; +} + +void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + else if (imageProcessor->mDownloader == nullptr) + { + ChipLogError(SoftwareUpdate, "mDownloader is null"); + return; + } + + if (NULL == imageProcessor->mNvsHandle) + { + NVS_Params nvsParams; + NVS_Params_init(&nvsParams); + imageProcessor->mNvsHandle = NVS_open(CONFIG_NVSEXTERNAL, &nvsParams); + + if (NULL == imageProcessor->mNvsHandle) + { + imageProcessor->mDownloader->OnPreparedForDownload(CHIP_ERROR_OPEN_FAILED); + return; + } + } + + if (!eraseExtSlot(imageProcessor->mNvsHandle)) + { + imageProcessor->mDownloader->OnPreparedForDownload(CHIP_ERROR_WRITE_FAILED); + } + + imageProcessor->mFixedOtaHeader = { 0 }; + imageProcessor->mDownloader->OnPreparedForDownload(CHIP_NO_ERROR); +} + +void OTAImageProcessorImpl::HandleFinalize(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + + if (imageProcessor == nullptr) + { + return; + } + + /* possible improvement, add MCUBoot magic at the end of the slot. This + * could be done if the ota file generation truncates the image instead of + * sending the full MCUBoot slot. + */ + + imageProcessor->ReleaseBlock(); + + ChipLogProgress(SoftwareUpdate, "OTA image downloaded"); + ChipLogProgress(SoftwareUpdate, "Total downloaded bytes: %d", (size_t) imageProcessor->mParams.downloadedBytes); +} + +void OTAImageProcessorImpl::HandleApply(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + return; + } + + /* reset SoC to kick MCUBoot */ + SysCtrlSystemReset(); +} + +void OTAImageProcessorImpl::HandleAbort(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + return; + } + + if (!eraseExtHeader(imageProcessor->mNvsHandle)) + { + imageProcessor->mDownloader->OnPreparedForDownload(CHIP_ERROR_WRITE_FAILED); + } + + NVS_close(imageProcessor->mNvsHandle); + imageProcessor->ReleaseBlock(); +} + +void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + else if (imageProcessor->mDownloader == nullptr) + { + ChipLogError(SoftwareUpdate, "mDownloader is null"); + return; + } + + /* Save the fixed size header */ + if (imageProcessor->mParams.downloadedBytes < sizeof(imageProcessor->mFixedOtaHeader)) + { + uint8_t * header = reinterpret_cast(&(imageProcessor->mFixedOtaHeader)); + if (imageProcessor->mBlock.size() + imageProcessor->mParams.downloadedBytes < sizeof(imageProcessor->mFixedOtaHeader)) + { + // the first block is smaller than the header, somehow + memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), imageProcessor->mBlock.size()); + } + else + { + // we have received the whole header, fill it up + memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), + sizeof(imageProcessor->mFixedOtaHeader) - imageProcessor->mParams.downloadedBytes); + + // update the total size for download tracking + imageProcessor->mParams.totalFileBytes = imageProcessor->mFixedOtaHeader.totalSize; + ChipLogDetail(SoftwareUpdate, "Total file size: %d", (size_t) imageProcessor->mParams.totalFileBytes); + } + } + + if (imageProcessor->mParams.downloadedBytes + imageProcessor->mBlock.size() > imageProcessor->mFixedOtaHeader.headerSize) + /* chip::OTAImageHeaderParser can be used for processing the variable size header */ + + /* Do not write Matter OTA image header to the external flash, MCUBoot + * needs to have it's header at address 0 + */ + if (imageProcessor->mFixedOtaHeader.headerSize > 0) + { + ssize_t offset = imageProcessor->mParams.downloadedBytes - + (imageProcessor->mFixedOtaHeader.headerSize + MATTER_OTA_HEADER_MAGIC_NUMBER_LENGTH + + MATTER_OTA_HEADER_IMG_LENGTH_BYTES + MATTER_OTA_HEADER_PADDING + MATTER_OTA_HEADER_LENGTH_BYTES); + ChipLogDetail(SoftwareUpdate, "Write block %d, %d", (size_t) imageProcessor->mParams.downloadedBytes, + imageProcessor->mBlock.size()); + if (!writeExtFlashImgPages(imageProcessor->mNvsHandle, offset, imageProcessor->mBlock)) + { + imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); + return; + } + } + + imageProcessor->mParams.downloadedBytes += imageProcessor->mBlock.size(); + ChipLogDetail(SoftwareUpdate, "Total downloaded bytes: %d", (size_t) imageProcessor->mParams.downloadedBytes); + imageProcessor->mDownloader->FetchNextData(); +} + +CHIP_ERROR OTAImageProcessorImpl::SetBlock(ByteSpan & block) +{ + if (!IsSpanUsable(block)) + { + ReleaseBlock(); + return CHIP_NO_ERROR; + } + if (mBlock.size() < block.size()) + { + if (!mBlock.empty()) + { + ReleaseBlock(); + } + uint8_t * mBlock_ptr = static_cast(chip::Platform::MemoryAlloc(block.size())); + if (mBlock_ptr == nullptr) + { + return CHIP_ERROR_NO_MEMORY; + } + mBlock = MutableByteSpan(mBlock_ptr, block.size()); + } + CHIP_ERROR err = CopySpanToMutableSpan(block, mBlock); + if (err != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Cannot copy block data: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ReleaseBlock() +{ + if (mBlock.data() != nullptr) + { + chip::Platform::MemoryFree(mBlock.data()); + } + + mBlock = MutableByteSpan(); + return CHIP_NO_ERROR; +} + +} // namespace chip diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/cc13x4_cc26x4_freertos_ota.lds b/src/platform/cc13xx_26xx/cc13x4_26x4/cc13x4_cc26x4_freertos_ota.lds index 83b05fb2716c79..a28b2669b3c0b8 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/cc13x4_cc26x4_freertos_ota.lds +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/cc13x4_cc26x4_freertos_ota.lds @@ -1,6 +1,7 @@ /* * * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2020 Texas Instruments Incorporated * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,19 +18,27 @@ /** * @file - * Linkerscript for Matter executable with space reserved for the TI BIM. + * Linkerscript for Matter executable with space reserved for MCUBoot. */ -STACKSIZE = 0x800; +STACKSIZE = 0x2000; MEMORY { - FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0xFF800 + MCUBOOT_HDR (RX) : ORIGIN = 0x00006000, LENGTH = 0x00000080 + FLASH (RX) : ORIGIN = 0x00006080, LENGTH = 0x000F8780 + /* + * NVS is the last 5 pages of slot, this area is not erased + * during OTA. The slot size for the primary and secondary slots + * is therefore 0xF6000 (MCUBoot Header + all the remaining space) + */ + /* FLASH_NVS (RX) : ORIGIN = 0x000FC000, LENGTH = 0x00002800 */ + FLASH_FACTORY_DATA (R) : ORIGIN = 0x000FE800, LENGTH = 0x900 /* * Customer Configuration Area and Bootloader Backdoor configuration in * flash */ - /* FLASH_CCFG (RX) : ORIGIN = 0x50000000, LENGTH = 0x00000800 */ + /* FLASH_CCFG (RX) : ORIGIN = 0x50000000, LENGTH = 0x00000800 */ SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00040000 GPRAM (RWX) : ORIGIN = 0x11000000, LENGTH = 0x00002000 /* Explicitly placed off target for the storage of logging data. @@ -42,6 +51,7 @@ MEMORY } REGION_ALIAS("REGION_TEXT", FLASH); +REGION_ALIAS("REGION_FACTORY_DATA", FLASH_FACTORY_DATA); REGION_ALIAS("REGION_BSS", SRAM); REGION_ALIAS("REGION_DATA", SRAM); REGION_ALIAS("REGION_STACK", SRAM); @@ -51,17 +61,9 @@ REGION_ALIAS("REGION_ARM_EXIDX", FLASH); REGION_ALIAS("REGION_ARM_EXTAB", FLASH); SECTIONS { - /* BIM header placed at the base of flash by default */ - PROVIDE (_img_header_base_address = - DEFINED(_img_header_base_address) ? _img_header_base_address : 0x0); - - .oad_image_header (_img_header_base_address) : AT (_img_header_base_address) { - KEEP (*(.oad_image_header)) - } > REGION_TEXT - - /* interrupt vectors shifted to accommodate BIM header */ + /* interrupt vectors shifted to accommodate MCUBoot header */ PROVIDE (_intvecs_base_address = - DEFINED(_intvecs_base_address) ? _intvecs_base_address : 0x100); + DEFINED(_intvecs_base_address) ? _intvecs_base_address : 0x6080); .resetVecs (_intvecs_base_address) : AT (_intvecs_base_address) { KEEP (*(.resetVecs)) @@ -74,6 +76,14 @@ SECTIONS { KEEP (*(.ramVecs)) } > REGION_DATA + /* Define base address for the Factory Data arrays and struct */ + PROVIDE (_factory_data_base_address = + DEFINED(_factory_data_base_address) ? _factory_data_base_address : 0xFE800); + + .factory_data(_factory_data_base_address) : AT (_factory_data_base_address) { + KEEP (*(.factory_data_struct)) + } > REGION_FACTORY_DATA + /* * UDMACC26XX_CONFIG_BASE below must match UDMACC26XX_CONFIG_BASE defined * by ti/drivers/dma/UDMACC26XX.h @@ -221,19 +231,19 @@ SECTIONS { /* End of executable code/data, NVS is not part of the OTA image */ PROVIDE (_flash_end_address = .); - /* Two pages of NV Memory (0x800 each) offset by 1 page for BIM/CCFG */ - .nvs (0xFE800) (NOLOAD) : AT (0xFE800) ALIGN(0x2000) { + /* 5 pages of NV Memory (0x800 each) at the end of Flash */ + .nvs (0xFC000) (NOLOAD) : AT (0xFC000) ALIGN(0x800) { *(.nvs) } > REGION_TEXT - /* CCFG is supplied by the BIM project */ + /* CCFG is supplied by the MCUBoot project */ /* .ccfg : { KEEP (*(.ccfg)) } > FLASH_CCFG AT> FLASH_CCFG */ - .bss : { + .bss (NOLOAD) : { __bss_start__ = .; *(.shbss) *(.bss) @@ -243,7 +253,7 @@ SECTIONS { __bss_end__ = .; } > REGION_BSS AT> REGION_BSS - .heap : { + .heap (NOLOAD) : { __heap_start__ = .; end = __heap_start__; _end = end; @@ -267,4 +277,4 @@ SECTIONS { } > REGION_LOG } -ENTRY(resetISR) +ENTRY(resetISR) \ No newline at end of file diff --git a/src/tracing/esp32_trace/esp32_tracing.cpp b/src/tracing/esp32_trace/esp32_tracing.cpp index 414cdd83edcc0d..24a7166dde04eb 100644 --- a/src/tracing/esp32_trace/esp32_tracing.cpp +++ b/src/tracing/esp32_trace/esp32_tracing.cpp @@ -17,6 +17,7 @@ */ #include "esp32_tracing.h" +#include #include #include #include @@ -26,6 +27,107 @@ namespace chip { namespace Tracing { namespace Insights { +namespace { + +constexpr size_t kPermitListMaxSize = 10; +using HashValue = uint32_t; + +// Implements a murmurhash with 0 seed. +uint32_t MurmurHash(const void * key) +{ + const uint32_t kMultiplier = 0x5bd1e995; + const uint32_t kShift = 24; + const unsigned char * data = (const unsigned char *) key; + uint32_t hash = 0; + + while (*data) + { + uint32_t value = *data++; + value *= kMultiplier; + value ^= value >> kShift; + value *= kMultiplier; + hash *= kMultiplier; + hash ^= value; + } + + hash ^= hash >> 13; + hash *= kMultiplier; + hash ^= hash >> 15; + + if (hash == 0) + { + ESP_LOGW("Tracing", "MurmurHash resulted in a hash value of 0"); + } + + return hash; +} + +/* PASESession,CASESession,NetworkCommissioning,GeneralCommissioning,OperationalCredentials + * are well known permitted entries. + */ + +HashValue gPermitList[kPermitListMaxSize] = { + MurmurHash("PASESession"), + MurmurHash("CASESession"), + MurmurHash("NetworkCommissioning"), + MurmurHash("GeneralCommissioning"), + MurmurHash("OperationalCredentials"), +}; + +bool IsPermitted(HashValue hashValue) +{ + for (HashValue permitted : gPermitList) + { + if (permitted == 0) + { + break; + } + if (hashValue == permitted) + { + return true; + } + } + return false; +} + +} // namespace + +namespace ESP32Filter { + +CHIP_ERROR AddHashToPermitlist(const char * str) +{ + HashValue hashValue = MurmurHash(str); + if (hashValue == 0) + { + ESP_LOGW("TRC", "Hash value for '%s' is 0", str); + return CHIP_ERROR_INCORRECT_STATE; + } + + for (HashValue & permitted : gPermitList) + { + if (permitted == 0) + { + permitted = hashValue; + return CHIP_NO_ERROR; + } + if (hashValue == permitted) + { + ESP_LOGW("TRC", "Hash value for '%s' is colliding with an existing entry", str); + return CHIP_ERROR_DUPLICATE_KEY_ID; + } + } + return CHIP_ERROR_NO_MEMORY; +} + +void RemoveHashFromPermitlist(const char * str) +{ + HashValue hashValue = MurmurHash(str); + + auto * end = gPermitList + kPermitListMaxSize; + std::fill(std::remove(gPermitList, end, hashValue), end, 0); +} + +} // namespace ESP32Filter #define LOG_HEAP_INFO(label, group, entry_exit) \ do \ @@ -48,12 +150,20 @@ void ESP32Backend::LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo & info) {} void ESP32Backend::TraceBegin(const char * label, const char * group) { - LOG_HEAP_INFO(label, group, "Entry"); + HashValue hashValue = MurmurHash(group); + if (IsPermitted(hashValue)) + { + LOG_HEAP_INFO(label, group, "Entry"); + } } void ESP32Backend::TraceEnd(const char * label, const char * group) { - LOG_HEAP_INFO(label, group, "Exit"); + HashValue hashValue = MurmurHash(group); + if (IsPermitted(hashValue)) + { + LOG_HEAP_INFO(label, group, "Exit"); + } } void ESP32Backend::TraceInstant(const char * label, const char * group) @@ -63,4 +173,3 @@ void ESP32Backend::TraceInstant(const char * label, const char * group) } // namespace Insights } // namespace Tracing } // namespace chip -// namespace chip diff --git a/src/tracing/esp32_trace/esp32_tracing.h b/src/tracing/esp32_trace/esp32_tracing.h index 9857eb111b2c3d..7fe783d817d8d8 100644 --- a/src/tracing/esp32_trace/esp32_tracing.h +++ b/src/tracing/esp32_trace/esp32_tracing.h @@ -1,11 +1,18 @@ +#include #include #include - namespace chip { namespace Tracing { namespace Insights { +// Provide the user the ability to add/remove trace filters. +namespace ESP32Filter { + +CHIP_ERROR AddHashToPermitlist(const char * alabel); +void RemoveHashFromPermitlist(const char * alabel); +} // namespace ESP32Filter + /// A Backend that outputs data to chip logging. /// /// Structured data is formatted as json strings. diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index 7655fd2d93d20d..0dc3ed029a019c 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit 7655fd2d93d20df1b975773fa8da917d6b5207a9 +Subproject commit 0dc3ed029a019c789283935a6fb10e7b7769d4a2 diff --git a/third_party/ot-br-posix/repo b/third_party/ot-br-posix/repo index 03132d34368f64..65294638fbf1d9 160000 --- a/third_party/ot-br-posix/repo +++ b/third_party/ot-br-posix/repo @@ -1 +1 @@ -Subproject commit 03132d34368f6403b12d63df740dd8a69f73483d +Subproject commit 65294638fbf1d9473c338746e21b137a9f8d1496 diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index e35aa3aecf78ae..c8c31a063f54a1 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit e35aa3aecf78ae4914e9559b77c57885a548a23d +Subproject commit c8c31a063f54a11ffdc32635c2d516876f4cc94b diff --git a/third_party/ti_simplelink_sdk/mcuboot/flash_map_backend.c b/third_party/ti_simplelink_sdk/mcuboot/flash_map_backend.c new file mode 100644 index 00000000000000..e28a64130828c1 --- /dev/null +++ b/third_party/ti_simplelink_sdk/mcuboot/flash_map_backend.c @@ -0,0 +1,662 @@ +/* + * Copyright (c) 2018 Nordic Semiconductor ASA + * Copyright (c) 2020 Cypress Semiconductor Corporation + * Copyright (c) 2021 Texas Instruments + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 "flash_map_backend.h" +#include "mcuboot_config/mcuboot_config.h" +#include + +#include "bootutil/bootutil_log.h" + +// clang-format off +#include +#include DeviceFamily_constructPath(driverlib/flash.h) + +#ifndef DeviceFamily_CC23X0R5 +#include DeviceFamily_constructPath(driverlib/vims.h) +#endif +// clang-format on + +#ifdef TI_BOOT_USE_EXTERNAL_FLASH +#include +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + +#define FLASH_BASE_ADDRESS 0 + +#ifdef DeviceFamily_CC23X0R5 +/* Remap driverlib API names that changed only for cc23x0 + */ +#define FlashSectorSizeGet FlashGetSectorSize +#define FlashSectorErase FlashEraseSector +#endif + +#define FLASH_ERASE_VALUE 0xFF + +/* XXX: Someone defined assert backwards in this file. We've changed it back to + * not conflict with the GCC assert. + +#define assert(x) if(x) {BOOT_LOG_ERR("assert: %s line %d", __FILE__, __LINE__);} +*/ +#include + +#ifdef TI_FLASH_MAP_EXT_DESC +/* Nothing to be there when external FlashMap Descriptors are used */ +#else +static const struct flash_area bootloader = { .fa_id = FLASH_AREA_BOOTLOADER, + .fa_device_id = FLASH_DEVICE_INTERNAL_FLASH, + .fa_off = BOOTLOADER_BASE_ADDRESS, + .fa_size = BOOT_BOOTLOADER_SIZE }; + +static const struct flash_area primary_1 = { .fa_id = FLASH_AREA_IMAGE_PRIMARY(0), + .fa_device_id = FLASH_DEVICE_INTERNAL_FLASH, + .fa_off = BOOT_PRIMARY_1_BASE_ADDRESS, + .fa_size = BOOT_PRIMARY_1_SIZE }; + +#if (MCUBOOT_IMAGE_NUMBER == 2) +static const struct flash_area primary_2 = { .fa_id = FLASH_AREA_IMAGE_PRIMARY(1), + .fa_device_id = FLASH_DEVICE_INTERNAL_FLASH, + .fa_off = BOOT_PRIMARY_2_BASE_ADDRESS, + .fa_size = BOOT_PRIMARY_2_SIZE }; +#endif + +static const struct flash_area secondary_1 = { .fa_id = FLASH_AREA_IMAGE_SECONDARY(0), +#ifndef TI_BOOT_USE_EXTERNAL_FLASH + .fa_device_id = FLASH_DEVICE_INTERNAL_FLASH, +#else + .fa_device_id = FLASH_DEVICE_EXTERNAL_FLASH(0), +#endif + .fa_off = BOOT_SECONDARY_1_BASE_ADDRESS, + .fa_size = BOOT_SECONDARY_1_SIZE }; + +#if (MCUBOOT_IMAGE_NUMBER == 2) +static const struct flash_area secondary_2 = { .fa_id = FLASH_AREA_IMAGE_SECONDARY(1), +#ifndef TI_BOOT_USE_EXTERNAL_FLASH + .fa_device_id = FLASH_DEVICE_INTERNAL_FLASH, +#else + .fa_device_id = FLASH_DEVICE_EXTERNAL_FLASH(0), +#endif + .fa_off = BOOT_SECONDARY_2_BASE_ADDRESS, + .fa_size = BOOT_SECONDARY_2_SIZE }; +#endif +#endif + +#if (MCUBOOT_IMAGE_NUMBER == 2) && (DeviceFamily_PARENT != DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4) +#error "MCUBOOT_IMAGE_NUMBER == 2 for current device not supported" +#endif + +#if (MCUBOOT_IMAGE_NUMBER > 2) +#error "More than 2 images not supported" +#endif + +#ifdef MCUBOOT_SWAP_USING_SCRATCH +static struct flash_area scratch = { +#error "MCUBOOT_SWAP_USING_SCRATCH not supported" +}; +#endif + +#ifdef TI_FLASH_MAP_EXT_DESC +/* Use external Flash Map Descriptors */ +extern struct flash_area * boot_area_descs[]; +#else +static const struct flash_area * boot_area_descs[] = { &bootloader, &primary_1, &secondary_1, +#if (MCUBOOT_IMAGE_NUMBER == 2) /* if dual-image */ + &primary_2, &secondary_2, +#endif +#ifdef MCUBOOT_SWAP_USING_SCRATCH + &scratch, +#endif + NULL }; +#endif + +#ifdef TI_BOOT_USE_EXTERNAL_FLASH +static bool extFlashStatus = false; +#endif + +#ifndef DeviceFamily_CC23X0R5 +/* Prepares system for a write to flash */ +static uint8_t disableCache(void) +{ + uint8_t mode = VIMSModeGet(VIMS_BASE); + + VIMSLineBufDisable(VIMS_BASE); + + if (mode != VIMS_MODE_DISABLED) + { + VIMSModeSet(VIMS_BASE, VIMS_MODE_DISABLED); + while (VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED) + ; + } + + return (mode); +} + +/* + * ======== restoreFlashCache ======== + */ +static void enableCache(uint8_t mode) +{ + if (mode != VIMS_MODE_DISABLED) + { + VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); + } + + VIMSLineBufEnable(VIMS_BASE); +} +#endif + +/* Returns device flash start based on supported fa_id */ +int flash_device_base(uint8_t fd_id, uintptr_t * ret) +{ + if ((fd_id != FLASH_DEVICE_INTERNAL_FLASH) || (fd_id != FLASH_DEVICE_EXTERNAL_FLASH(0))) + { + BOOT_LOG_ERR("invalid flash ID %d", fd_id); + return -1; + } + *ret = FLASH_BASE_ADDRESS; + return 0; +} + +/* Opens the area for use. id is one of the `fa_id`s */ +int flash_area_open(uint8_t id, const struct flash_area ** fa) +{ + int ret = -1; + uint32_t i = 0; + + while (NULL != boot_area_descs[i]) + { + if (id == boot_area_descs[i]->fa_id) + { + *fa = boot_area_descs[i]; + +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + if (boot_area_descs[i]->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + if (!extFlashStatus) + { + ret = !extFlashOpen(); + // if the external flash has been opened, update the status + if (ret == 0) + { + extFlashStatus = true; + } + } + else + { + ret = 0; + } + } + else + { + ret = 0; + } +#else + ret = 0; +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + break; + } + i++; + } + return ret; +} + +void flash_area_close(const struct flash_area * fa) +{ +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + if (fa->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + if (extFlashStatus) + { + extFlashClose(); + extFlashStatus = false; + } + } +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + + (void) fa; /* Nothing to do there */ +} + +/* + * Reads `len` bytes of flash memory at `off` to the buffer at `dst` + */ +int flash_area_read(const struct flash_area * fa, uint32_t off, void * dst, uint32_t len) +{ + int rc = 0; + size_t addr; + + /* convert to absolute address inside a device*/ + addr = fa->fa_off + off; + + /* check if read is within bounds */ + assert((addr + len) <= (fa->fa_off + fa->fa_size)); + + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + /* flash read by simple memory copying */ + memcpy((void *) dst, (const void *) addr, (size_t) len); + } +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + else if (fa->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + /* verify that flash is open */ + if (!extFlashStatus) + { + rc = flash_area_open(fa->fa_id, &fa); + if (rc != 0) + { + return rc; + } + } + else + { + extFlashClose(); + rc = !extFlashOpen(); + // if the external flash has been opened, update the status + if (rc == 0) + { + extFlashStatus = true; + } + } + + /* Read whole metadata header */ + rc = !extFlashRead(addr, (size_t) len, (void *) dst); + } +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + else + { + /* incorrect/non-existing flash device id */ + rc = -1; + } + + if (rc != 0) + { + BOOT_LOG_ERR("Flash area read error, rc = %d", (int) rc); + } + return rc; +} + +/* + * Writes `len` bytes of flash memory at `off` from the buffer at `src` + */ +int flash_area_write(const struct flash_area * fa, uint32_t off, const void * src, uint32_t len) +{ + int rc = -1; + size_t write_start_addr; + + /* convert to absolute address inside a device*/ + write_start_addr = fa->fa_off + off; + + /* check if read is within bounds */ + assert((write_start_addr + len) <= (fa->fa_off + fa->fa_size)); + + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + uint32_t flashStat; +#ifndef DeviceFamily_CC23X0R5 + uint8_t cacheState = disableCache(); +#endif + + flashStat = FlashProgram((uint8_t *) src, write_start_addr, len); + if (flashStat == FAPI_STATUS_SUCCESS) + { + rc = 0; + } + +#ifndef DeviceFamily_CC23X0R5 + enableCache(cacheState); +#endif + } +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + else if (fa->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + /* verify that flash is open */ + if (!extFlashStatus) + { + rc = flash_area_open(fa->fa_id, &fa); + if (rc != 0) + { + return rc; + } + } + + rc = !extFlashWrite(write_start_addr, (size_t) len, (uint8_t *) src); + } +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + else + { + /* incorrect/non-existing flash device id */ + rc = -1; + } + + return rc; +} + +/*< Erases `len` bytes of flash memory at `off` */ +int flash_area_erase(const struct flash_area * fa, uint32_t off, uint32_t len) +{ + int rc = -1; + size_t erase_start_addr; + + /* convert to absolute address inside a device*/ + erase_start_addr = fa->fa_off + off; + + /* check if read is within bounds */ + assert((erase_start_addr + len) <= (fa->fa_off + fa->fa_size)); + + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + uint8_t flashStat; + uint32_t pageAddr; + uint32_t sectorSize = FlashSectorSizeGet(); + + assert(0 == erase_start_addr % sectorSize); + +#ifndef DeviceFamily_CC23X0R5 + uint8_t cacheState = disableCache(); +#endif + + for (pageAddr = erase_start_addr; pageAddr < erase_start_addr + len; pageAddr += sectorSize) + { + flashStat = FlashSectorErase(pageAddr); + if (flashStat != FAPI_STATUS_SUCCESS) + { +#ifndef DeviceFamily_CC23X0R5 + enableCache(cacheState); +#endif + return rc; + } + } + +#ifndef DeviceFamily_CC23X0R5 + enableCache(cacheState); +#endif + rc = 0; + } +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + else if (fa->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + assert(0 == erase_start_addr % EXT_FLASH_PAGE_SIZE); + + /* verify that flash is open */ + if (!extFlashStatus) + { + rc = flash_area_open(fa->fa_id, &fa); + if (rc != 0) + { + return rc; + } + } + rc = !extFlashErase(erase_start_addr, (size_t) len); + } +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + else + { + /* incorrect/non-existing flash device id */ + rc = -1; + } + return (int) rc; +} + +/*< Returns this `flash_area`s alignment */ +size_t flash_area_align(const struct flash_area * fa) +{ + int ret = -1; + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + ret = FlashSectorSizeGet(); + } +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + if (fa->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + ret = EXT_FLASH_PAGE_SIZE; + } +#endif /* TI_BOOT_USE_EXTERNAL_FLASH */ + else + { + /* incorrect/non-existing flash device id */ + ret = -1; + } + return ret; +} + +#ifndef MCUBOOT_USE_FLASH_AREA_GET_SECTORS +/*< Initializes an array of flash_area elements for the slot's sectors */ +int flash_area_to_sectors(int idx, int * cnt, struct flash_area * fa) +{ + int rc = 0; + + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + (void) idx; + (void) cnt; + rc = 0; + } + else + { + /* incorrect/non-existing flash device id */ + rc = -1; + } + return rc; +} +#endif + +/* + * This depends on the mappings defined in sysflash.h. + * MCUBoot uses continuous numbering for the primary slot, the secondary slot, + * and the scratch while zephyr might number it differently. + */ +int flash_area_id_from_multi_image_slot(int image_index, int slot) +{ + switch (slot) + { + case 0: + return FLASH_AREA_IMAGE_PRIMARY(image_index); + case 1: + return FLASH_AREA_IMAGE_SECONDARY(image_index); + case 2: + return FLASH_AREA_IMAGE_SCRATCH; + } + + return -1; /* flash_area_open will fail on that */ +} + +int flash_area_id_from_image_slot(int slot) +{ + return flash_area_id_from_multi_image_slot(0, slot); +} + +int flash_area_id_to_multi_image_slot(int image_index, int area_id) +{ + if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index)) + { + return 0; + } + if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) + { + return 1; + } + + return -1; +} + +int flash_area_id_to_image_slot(int area_id) +{ + return flash_area_id_to_multi_image_slot(0, area_id); +} + +uint8_t flash_area_erased_val(const struct flash_area * fap) +{ + int ret = 0; + + if ((fap->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) || (fap->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0))) + { + ret = FLASH_ERASE_VALUE; + } + else + { + assert(false); + } + + return ret; +} + +int flash_area_read_is_empty(const struct flash_area * fa, uint32_t off, void * dst, uint32_t len) +{ + uint8_t * mem_dest; + int rc; + + mem_dest = (uint8_t *) dst; + rc = flash_area_read(fa, off, dst, len); + if (rc) + { + return -1; + } + + for (uint8_t i = 0; i < len; i++) + { + if (mem_dest[i] != flash_area_erased_val(fa)) + { + return 0; + } + } + return 1; +} + +#ifdef MCUBOOT_USE_FLASH_AREA_GET_SECTORS +int flash_area_get_sectors(int idx, uint32_t * cnt, struct flash_sector * ret) +{ + int rc = 0; + uint32_t i = 0; + struct flash_area * fa = NULL; + + while (NULL != boot_area_descs[i]) + { + if (idx == boot_area_descs[i]->fa_id) + { + fa = (struct flash_area *) boot_area_descs[i]; + break; + } + i++; + } + + if (NULL != boot_area_descs[i]) + { + size_t sector_size = 0; + + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + sector_size = FlashSectorSizeGet(); + } +#ifdef TI_BOOT_USE_EXTERNAL_FLASH + else if (fa->fa_device_id == FLASH_DEVICE_EXTERNAL_FLASH(0)) + { + sector_size = EXT_FLASH_PAGE_SIZE; + } +#endif + else + { + rc = -1; + } + + if (0 == rc) + { + uint32_t addr = 0; + size_t sectors_n = 0; + + sectors_n = (fa->fa_size + (sector_size - 1)) / sector_size; + assert(sectors_n <= *cnt); + + addr = fa->fa_off; + for (i = 0; i < sectors_n; i++) + { + ret[i].fs_size = sector_size; + ret[i].fs_off = addr; + addr += sector_size; + } + + *cnt = sectors_n; + } + } + else + { + rc = -1; + } + + return rc; +} +#endif + +#ifdef MCUBOOT_HW_ROLLBACK_PROT + +#ifdef DeviceFamily_CC23X0R5 + +#define FLASH_WRITE_PROTECT 0 + +/* + * There is no implementation of FlashProtectionSet() in cc23x0 driverlib. + * For now it was decided to implement this feature directly in this module. + * + */ + +static void FlashProtectionSet(uint32_t address, uint32_t mode) +{ + uint32_t sector_number; + uint32_t sector_size = FlashSectorSizeGet(); + uint32_t mask; + + /* + * Check that address is within expected range, as in cc23x0r5 + * only the first 32 sectors can be individually locked. + */ + if ((address >= (FLASH_MAIN_BASE + (32 * sector_size))) || (0 != (address & (sector_size - 1)))) + { + return; + } + + sector_number = (address - FLASH_MAIN_BASE) / sector_size; + mask = 1 << sector_number; + + HWREG(VIMS_BASE + VIMS_O_WEPRA) &= ~mask; +} +#endif + +void flash_area_lock(const struct flash_area * fa) +{ + size_t addr; + + /* convert to absolute address inside a device*/ + addr = fa->fa_off; + + if (fa->fa_device_id == FLASH_DEVICE_INTERNAL_FLASH) + { + FlashProtectionSet(addr, FLASH_WRITE_PROTECT); + } +} +#endif diff --git a/third_party/ti_simplelink_sdk/mcuboot/flash_map_backend.h b/third_party/ti_simplelink_sdk/mcuboot/flash_map_backend.h new file mode 100644 index 00000000000000..728e2ef44cf882 --- /dev/null +++ b/third_party/ti_simplelink_sdk/mcuboot/flash_map_backend.h @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2018 Nordic Semiconductor ASA + * Copyright (c) 2015 Runtime Inc + * Copyright (c) 2020 Cypress Semiconductor Corporation + * Copyright (c) 2021 Texas Instruments + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +/*******************************************************************************/ + +// clang-fomat off +#ifndef __FLASH_MAP_BACKEND_H__ +#define __FLASH_MAP_BACKEND_H__ + +#include +#define FLASH_DEVICE_INDEX_MASK (0x7F) +#define FLASH_DEVICE_GET_EXT_INDEX(n) ((n) &FLASH_DEVICE_INDEX_MASK) +#define FLASH_DEVICE_EXTERNAL_FLAG (0x80) +#define FLASH_DEVICE_INTERNAL_FLASH (0x7F) +#define FLASH_DEVICE_EXTERNAL_FLASH(index) (FLASH_DEVICE_EXTERNAL_FLAG | index) + +#ifndef TI_BOOT_EXTERNAL_DEVICE_INDEX +/* assume first(one) SMIF device is used */ +#define TI_BOOT_EXTERNAL_DEVICE_INDEX (0) +#endif + +/* + * ============== XXX: Definitions changed from upstream example ============== + * + * These definitions have been modified to work with the Matter examples. + * Currently the example application takes up as much flash space as possible + * in the SoC. This may change in the future when a secure image is produced. + * + * This is for external flash storage of the secondary image + */ +#ifndef TI_BOOT_USE_EXTERNAL_FLASH +#error "This file must be used with TI_BOOT_USE_EXTERNAL_FLASH enabled" +#endif + +#ifdef DeviceFamily_CC13X4 +#if (MCUBOOT_IMAGE_NUMBER == 2) +#define BOOT_SLOT_1_SIZE 0x0002B000 +#define BOOT_SLOT_2_SIZE 0x000CC800 + +/* Internal Flash locations */ +#define BOOTLOADER_BASE_ADDRESS 0x00000800 +#define BOOT_BOOTLOADER_SIZE 0x00005800 + +#define BOOT_PRIMARY_1_BASE_ADDRESS (BOOTLOADER_BASE_ADDRESS + BOOT_BOOTLOADER_SIZE) +#define BOOT_PRIMARY_1_SIZE BOOT_SLOT_1_SIZE + +#define BOOT_PRIMARY_2_BASE_ADDRESS (BOOT_PRIMARY_1_BASE_ADDRESS + BOOT_PRIMARY_1_SIZE) +#define BOOT_PRIMARY_2_SIZE BOOT_SLOT_2_SIZE + +/* EXT Flash locations */ +#define BOOT_SECONDARY_1_BASE_ADDRESS 0x00000000 +#define BOOT_SECONDARY_1_SIZE BOOT_SLOT_1_SIZE + +#define BOOT_SECONDARY_2_BASE_ADDRESS (BOOT_SECONDARY_1_BASE_ADDRESS + BOOT_SECONDARY_1_SIZE) +#define BOOT_SECONDARY_2_SIZE BOOT_SLOT_2_SIZE +#else +#define BOOT_SLOT_1_SIZE 0x000F6000 + +/* Internal Flash locations */ +#define BOOTLOADER_BASE_ADDRESS 0x00000000 +#define BOOT_BOOTLOADER_SIZE 0x00006000 + +#define BOOT_PRIMARY_1_BASE_ADDRESS (BOOTLOADER_BASE_ADDRESS + BOOT_BOOTLOADER_SIZE) +#define BOOT_PRIMARY_1_SIZE BOOT_SLOT_1_SIZE + +/* EXT Flash locations */ +#define BOOT_SECONDARY_1_BASE_ADDRESS 0x00000000 +#define BOOT_SECONDARY_1_SIZE BOOT_SLOT_1_SIZE +#endif + +#else +#error "DeviceFamily not recognized, is MCUBoot meant to be used?" + +#endif /* DeviceFamily_XXXXXX */ + +/** + * + * Provides abstraction of flash regions for type of use. + * I.e. dude where's my image? + * + * System will contain a map which contains flash areas. Every + * region will contain flash identifier, offset within flash and length. + * + * 1. This system map could be in a file within filesystem (Initializer + * must know/figure out where the filesystem is at). + * 2. Map could be at fixed location for project (compiled to code) + * 3. Map could be at specific place in flash (put in place at mfg time). + * + * Note that the map you use must be valid for BSP it's for, + * match the linker scripts when platform executes from flash, + * and match the target offset specified in download script. + */ +#include + +/** + * @brief Structure describing an area on a flash device. + * + * Multiple flash devices may be available in the system, each of + * which may have its own areas. For this reason, flash areas track + * which flash device they are part of. + */ +struct flash_area +{ + /** + * This flash area's ID; unique in the system. + */ + uint8_t fa_id; + + /** + * ID of the flash device this area is a part of. + */ + uint8_t fa_device_id; + + uint16_t pad16; + + /** + * This area's offset, relative to the beginning of its flash + * device's storage. + */ + uint32_t fa_off; + + /** + * This area's size, in bytes. + */ + uint32_t fa_size; +}; + +/** + * @brief Structure describing a sector within a flash area. + * + * Each sector has an offset relative to the start of its flash area + * (NOT relative to the start of its flash device), and a size. A + * flash area may contain sectors with different sizes. + */ +struct flash_sector +{ + /** + * Offset of this sector, from the start of its flash area (not device). + */ + uint32_t fs_off; + + /** + * Size of this sector, in bytes. + */ + uint32_t fs_size; +}; + +struct flash_map_entry +{ + uint32_t magic; + struct flash_area area; + unsigned int ref_count; +}; + +/* + * Retrieve a memory-mapped flash device's base address. + * On success, the address will be stored in the value pointed to by + * ret. + * Returns 0 on success, or an error code on failure. + */ +int flash_device_base(uint8_t fd_id, uintptr_t * ret); + +/*< Opens the area for use. id is one of the `fa_id`s */ +int flash_area_open(uint8_t id, const struct flash_area **); +void flash_area_close(const struct flash_area *); +/*< Reads `len` bytes of flash memory at `off` to the buffer at `dst` */ +int flash_area_read(const struct flash_area *, uint32_t off, void * dst, uint32_t len); +/*< Writes `len` bytes of flash memory at `off` from the buffer at `src` */ +int flash_area_write(const struct flash_area *, uint32_t off, const void * src, uint32_t len); +/*< Erases `len` bytes of flash memory at `off` */ +int flash_area_erase(const struct flash_area *, uint32_t off, uint32_t len); +/*< Returns this `flash_area`s alignment */ +size_t flash_area_align(const struct flash_area *); +/*< Initializes an array of flash_area elements for the slot's sectors */ +int flash_area_to_sectors(int idx, int * cnt, struct flash_area * ret); +/*< Returns the `fa_id` for slot, where slot is 0 (primary) or 1 (secondary) */ +int flash_area_id_from_image_slot(int slot); +/*< Returns the slot, for the `fa_id` supplied */ +int flash_area_id_to_image_slot(int area_id); + +int flash_area_id_from_multi_image_slot(int image_index, int slot); +int flash_area_id_to_multi_image_slot(int image_index, int area_id); +#ifdef MCUBOOT_USE_FLASH_AREA_GET_SECTORS +int flash_area_get_sectors(int idx, uint32_t * cnt, struct flash_sector * ret); +#endif +#ifdef MCUBOOT_HW_ROLLBACK_PROT +void flash_area_lock(const struct flash_area * fa); +#endif +/* + * Returns the value expected to be read when accesing any erased + * flash byte. + */ +uint8_t flash_area_erased_val(const struct flash_area * fap); + +/* + * Reads len bytes from off, and checks if the read data is erased. + * + * Returns 1 if erased, 0 if non-erased, and -1 on failure. + */ +int flash_area_read_is_empty(const struct flash_area * fa, uint32_t off, void * dst, uint32_t len); + +#endif /* __FLASH_MAP_BACKEND_H__ */ + +// clang-format on diff --git a/third_party/ti_simplelink_sdk/mcuboot/mcuboot.syscfg b/third_party/ti_simplelink_sdk/mcuboot/mcuboot.syscfg new file mode 100644 index 00000000000000..0a92846df1c88e --- /dev/null +++ b/third_party/ti_simplelink_sdk/mcuboot/mcuboot.syscfg @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2022, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * mcuboot.syscfg + */ + + +const Board = scripting.addModule("/ti/drivers/Board"); + +/* ======== Board ======== */ +var boardName = system.deviceData.board.name; + +/** + * Import the modules used in this configuration. + */ +const CCFG = scripting.addModule("/ti/devices/CCFG"); +const ccfgSettings = system.getScript("/ti/common/lprf_ccfg_settings.js").ccfgSettings; +for(var setting in ccfgSettings) +{ + CCFG[setting] = ccfgSettings[setting]; +} + +if (boardName.match(/CC13.2.7|CC26.2.7/)) +{ + // mcuboot stored at end of flash alongside CCFG + CCFG.setFlashVectorTable = true; + CCFG.addressFlashVectorTable = 0x000AC000; +} +else if (boardName.match(/CC13.4|CC26.[34]/)) +{ + // mcuboot stored at the beginning of flash + CCFG.setFlashVectorTable = true; + CCFG.addressFlashVectorTable = 0x00000000; +} +else if (boardName.match(/CC23.0/)) { + // Nothing to do. Default pBldrVtor = 0x00000000 +} +else +{ + // error +} + +CCFG.ccfgTemplate.$name = "ti_devices_CCFG_CCFGCC26XXTemplate0"; + +/* ======== GPIO ======== */ +var GPIO = scripting.addModule("/ti/drivers/GPIO"); + +var gpio0 = GPIO.addInstance(); +gpio0.$hardware = system.deviceData.board.components.LED0; +gpio0.$name = "CONFIG_GPIO_LED_0"; + +var gpio1 = GPIO.addInstance(); +gpio1.$hardware = system.deviceData.board.components.LED1; +gpio1.$name = "CONFIG_GPIO_LED_1"; + +var gpio2 = GPIO.addInstance(); +gpio2.$hardware = system.deviceData.board.components.BUTTON0; +gpio2.$name = "CONFIG_GPIO_BUTTON_0"; + +var gpio3 = GPIO.addInstance(); +gpio3.$hardware = system.deviceData.board.components.BUTTON1; +gpio3.$name = "CONFIG_GPIO_BUTTON_1"; \ No newline at end of file diff --git a/third_party/ti_simplelink_sdk/mcuboot/mcuboot_cc13x4_cc26x4.lds b/third_party/ti_simplelink_sdk/mcuboot/mcuboot_cc13x4_cc26x4.lds new file mode 100644 index 00000000000000..375e18722dc49e --- /dev/null +++ b/third_party/ti_simplelink_sdk/mcuboot/mcuboot_cc13x4_cc26x4.lds @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2022, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +STACKSIZE = 1024; +HEAPSIZE = 16384; /* Size of heap buffer used by HeapMem */ + +FLASH_BASE = DEFINED(DUAL_SLOT) ? 0x800 : 0x0; + +MEMORY +{ + FLASH (RX) : ORIGIN = FLASH_BASE, LENGTH = 0x5800 + /* + * Customer Configuration Area and Bootloader Backdoor configuration in + * flash, up to 1024 bytes + */ + FLASH_CCFG (RX) : ORIGIN = 0x50000000, LENGTH = 0x00000800 + SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00040000 + GPRAM (RWX) : ORIGIN = 0x11000000, LENGTH = 0x00002000 +} + +REGION_ALIAS("REGION_FLASH_START", FLASH); +REGION_ALIAS("REGION_TEXT", FLASH); +REGION_ALIAS("REGION_BSS", SRAM); +REGION_ALIAS("REGION_DATA", SRAM); +REGION_ALIAS("REGION_STACK", SRAM); +REGION_ALIAS("REGION_HEAP", SRAM); +REGION_ALIAS("REGION_ARM_EXIDX", FLASH); +REGION_ALIAS("REGION_ARM_EXTAB", FLASH); + +SECTIONS { + + .resetVecs : { + KEEP (*(.resetVecs)) + } > REGION_FLASH_START + + .ramVecs (NOLOAD) : ALIGN(1024){ + KEEP (*(.ramVecs)) + } > REGION_DATA + + /* + * UDMACC26XX_CONFIG_BASE below must match UDMACC26XX_CONFIG_BASE defined + * by ti/drivers/dma/UDMACC26XX.h + * The user is allowed to change UDMACC26XX_CONFIG_BASE to move it away from + * the default address 0x2000_0400, but remember it must be 1024 bytes aligned. + */ + UDMACC26XX_CONFIG_BASE = 0x20000400; + + /* + * Define absolute addresses for the DMA channels. + * DMA channels must always be allocated at a fixed offset from the DMA base address. + * --------- DO NOT MODIFY ----------- + */ + DMA_UART0_RX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x10); + DMA_UART0_TX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x20); + DMA_SPI0_RX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x30); + DMA_SPI0_TX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x40); + DMA_UART1_RX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x50); + DMA_UART1_TX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x60); + DMA_ADC_PRI_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x70); + DMA_GPT0A_PRI_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x90); + DMA_SPI1_RX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x100); + DMA_SPI1_TX_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x110); + + DMA_UART0_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x210); + DMA_UART0_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x220); + DMA_SPI0_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x230); + DMA_SPI0_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x240); + DMA_UART1_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x250); + DMA_UART1_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x260); + DMA_ADC_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x270); + DMA_GPT0A_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x290); + DMA_SPI1_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x300); + DMA_SPI1_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS = (UDMACC26XX_CONFIG_BASE + 0x310); + + /* + * Allocate UART0, UART1, SPI0, SPI1, ADC, and GPTimer0 DMA descriptors at absolute addresses. + * --------- DO NOT MODIFY ----------- + */ + UDMACC26XX_uart0RxControlTableEntry_is_placed = 0; + .dmaUart0RxControlTableEntry DMA_UART0_RX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART0_RX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart0RxControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart0TxControlTableEntry_is_placed = 0; + .dmaUart0TxControlTableEntry DMA_UART0_TX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART0_TX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart0TxControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi0RxControlTableEntry_is_placed = 0; + .dmaSpi0RxControlTableEntry DMA_SPI0_RX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI0_RX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi0RxControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi0TxControlTableEntry_is_placed = 0; + .dmaSpi0TxControlTableEntry DMA_SPI0_TX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI0_TX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi0TxControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart1RxControlTableEntry_is_placed = 0; + .dmaUart1RxControlTableEntry DMA_UART1_RX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART1_RX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart1RxControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart1TxControlTableEntry_is_placed = 0; + .dmaUart1TxControlTableEntry DMA_UART1_TX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART1_TX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart1TxControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaADCPriControlTableEntry_is_placed = 0; + .dmaADCPriControlTableEntry DMA_ADC_PRI_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_ADC_PRI_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaADCPriControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaGPT0APriControlTableEntry_is_placed = 0; + .dmaGPT0APriControlTableEntry DMA_GPT0A_PRI_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_GPT0A_PRI_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaGPT0APriControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi1RxControlTableEntry_is_placed = 0; + .dmaSpi1RxControlTableEntry DMA_SPI1_RX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI1_RX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi1RxControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi1TxControlTableEntry_is_placed = 0; + .dmaSpi1TxControlTableEntry DMA_SPI1_TX_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI1_TX_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi1TxControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart0RxAltControlTableEntry_is_placed = 0; + .dmaUart0RxAltControlTableEntry DMA_UART0_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART0_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart0RxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart0TxAltControlTableEntry_is_placed = 0; + .dmaUart0TxAltControlTableEntry DMA_UART0_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART0_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart0TxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi0RxAltControlTableEntry_is_placed = 0; + .dmaSpi0RxAltControlTableEntry DMA_SPI0_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI0_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi0RxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi0TxAltControlTableEntry_is_placed = 0; + .dmaSpi0TxAltControlTableEntry DMA_SPI0_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI0_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi0TxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart1RxAltControlTableEntry_is_placed = 0; + .dmaUart1RxAltControlTableEntry DMA_UART1_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART1_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart1RxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_uart1TxAltControlTableEntry_is_placed = 0; + .dmaUart1TxAltControlTableEntry DMA_UART1_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_UART1_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaUart1TxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaADCAltControlTableEntry_is_placed = 0; + .dmaADCAltControlTableEntry DMA_ADC_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_ADC_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaADCAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaGPT0AAltControlTableEntry_is_placed = 0; + .dmaGPT0AAltControlTableEntry DMA_GPT0A_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_GPT0A_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaGPT0AAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi1RxAltControlTableEntry_is_placed = 0; + .dmaSpi1RxAltControlTableEntry DMA_SPI1_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI1_RX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi1RxAltControlTableEntry)} > REGION_DATA + + UDMACC26XX_dmaSpi1TxAltControlTableEntry_is_placed = 0; + .dmaSpi1TxAltControlTableEntry DMA_SPI1_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS (NOLOAD) : AT (DMA_SPI1_TX_ALT_CONTROL_TABLE_ENTRY_ADDRESS) {*(.dmaSpi1TxAltControlTableEntry)} > REGION_DATA + + .text : { + CREATE_OBJECT_SYMBOLS + *(.text) + *(.text.*) + . = ALIGN(0x4); + KEEP (*(.ctors)) + . = ALIGN(0x4); + KEEP (*(.dtors)) + . = ALIGN(0x4); + __init_array_start = .; + KEEP (*(.init_array*)) + __init_array_end = .; + *(.init) + *(.fini*) + } > REGION_TEXT AT> REGION_TEXT + + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + + .rodata : { + *(.rodata) + *(.rodata.*) + } > REGION_TEXT AT> REGION_TEXT + + .data : ALIGN(4) { + _data = .; + __data_load__ = LOADADDR (.data); + __data_start__ = .; + *(.data) + *(.data.*) + _edata = .; + . = ALIGN (4); + __data_end__ = .; + } > REGION_DATA AT> REGION_TEXT + _ldata = LOADADDR(.data); + + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + __exidx_end = .; + } > REGION_ARM_EXIDX AT> REGION_ARM_EXIDX + + .ARM.extab : { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > REGION_ARM_EXTAB AT> REGION_ARM_EXTAB + + .nvs (NOLOAD) : ALIGN(0x2000) { + *(.nvs) + } > REGION_TEXT + + .ccfg : { + KEEP (*(.ccfg)) + } > FLASH_CCFG AT> FLASH_CCFG + + .bss : { + __bss_start__ = .; + *(.shbss) + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN (4); + _ebss = .; + __bss_end__ = .; + } > REGION_BSS AT> REGION_BSS + _bss = LOADADDR(.bss); + + .heap : { + __heap_start__ = .; + end = __heap_start__; + _end = end; + __end = end; + . = . + HEAPSIZE; + KEEP(*(.heap)) + __heap_end__ = .; + __HeapLimit = __heap_end__; + } > REGION_HEAP AT> REGION_HEAP + + .stack (NOLOAD) : ALIGN(0x8) { + _stack = .; + __stack = .; + KEEP(*(.stack)) + . += STACKSIZE; + _stack_end = .; + __stack_end = .; + _estack = .; + } > REGION_STACK AT> REGION_STACK +} \ No newline at end of file diff --git a/third_party/ti_simplelink_sdk/mcuboot/mcuboot_config/mcuboot_config.h b/third_party/ti_simplelink_sdk/mcuboot/mcuboot_config/mcuboot_config.h new file mode 100644 index 00000000000000..1977bb7af88f4d --- /dev/null +++ b/third_party/ti_simplelink_sdk/mcuboot/mcuboot_config/mcuboot_config.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Texas Instruments Incorporated + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + +#define MCUBOOT_DOWNGRADE_PREVENTION +#define MCUBOOT_HAVE_LOGGING 1 +#define MCUBOOT_IMAGE_NUMBER 1 +#define MCUBOOT_MAX_IMG_SECTORS 492 +#define MCUBOOT_OVERWRITE_ONLY +#define MCUBOOT_SIGN_EC256 +#define MCUBOOT_USE_FLASH_AREA_GET_SECTORS +#define MCUBOOT_USE_TI_CRYPTO +#define MCUBOOT_VALIDATE_PRIMARY_SLOT +#define MCUBOOT_WATCHDOG_FEED() \ + {} + +#define TI_BOOT_USE_EXTERNAL_FLASH + +#ifdef MCUBOOT_DATA_SHARING +#define MCUBOOT_SHARED_DATA_BASE 0x20000000 +#define MCUBOOT_SHARED_DATA_SIZE 0x400 +#endif + +#if defined(TI_BOOT_USE_EXTERNAL_FLASH) && (!defined(MCUBOOT_OVERWRITE_ONLY) || defined(MCUBOOT_DIRECT_XIP)) +#error "If external flash is configured, only MCUBOOT_OVERWRITE_ONLY is supported" +#endif diff --git a/third_party/ti_simplelink_sdk/oad_merge_tool.py b/third_party/ti_simplelink_sdk/oad_merge_tool.py index c603a2fe445b58..0554601a1da07c 100644 --- a/third_party/ti_simplelink_sdk/oad_merge_tool.py +++ b/third_party/ti_simplelink_sdk/oad_merge_tool.py @@ -14,12 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Simple hexmerge script for combining the BIM and App +"""Simple hexmerge script for combining the BIM/MCUBoot image and App -This script provides a basic utility to combine the OAD application binary file with the Boot Image Manager hex file. The output is a combined hex file that can be programmed on the target and run. +This script provides a basic utility to combine the OAD application binary file with the Boot Image Manager/MCUBoot hex file. The output is a combined hex file that can be programmed on the target and run. Run with: - python oad_merge_tool.py + python oad_merge_tool.py """ import sys @@ -32,7 +32,11 @@ # merge binary executable with bim hex file ota_image = intelhex.IntelHex() -ota_image.fromfile(oad_bin_file, format='bin') +if (oad_bin_file.endswith('hex')): + ota_image.fromfile(oad_bin_file, format='hex') + +else: + ota_image.fromfile(oad_bin_file, format='bin') bim_hex = intelhex.IntelHex() bim_hex.fromfile(bim_hex_file, format='hex') diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index da4dff87a73460..9cc800e9b1e139 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -37,13 +37,6 @@ assert(matter_software_ver_str != "", template("ti_simplelink_executable") { simplelink_target_name = target_name - if (chip_enable_ota_requestor) { - # Generating the ota binary image - final_target = "${target_name}.ota" - } else { - # The executable is the final target. - final_target = "${simplelink_target_name}.out" - } output_base_name = get_path_info(invoker.output_name, "name") #used for OTA image creator for the cc13xx @@ -109,103 +102,339 @@ template("ti_simplelink_executable") { ] } - if (chip_enable_ota_requestor && - ti_simplelink_device_family == "cc13x2x7_26x2x7") { - pw_python_action("${simplelink_target_name}.bin") { - public_deps = [ ":${simplelink_target_name}.out.image" ] - - script = "${ti_simplelink_sdk_root}//tools/common/oad/oad_image_tool.py" - sources = [ "${root_out_dir}/${objcopy_image_name}" ] - outputs = [ "${root_out_dir}/${output_base_name}.bin" ] - - args = [ - "--verbose", - "ccs", - rebase_path(root_out_dir, root_build_dir), - "7", - "-hex1", - rebase_path("${root_out_dir}/${output_base_name}.hex", root_out_dir), - "-o", - output_base_name, - ] - - if (defined(invoker.pem_file)) { - args += [ - "-k", - rebase_path(invoker.pem_file, root_build_dir), + if (chip_enable_ota_requestor) { + if (ti_simplelink_device_family == "cc13x2x7_26x2x7") { + pw_python_action("${simplelink_target_name}.bin") { + public_deps = [ ":${simplelink_target_name}.out.image" ] + + script = "${ti_simplelink_sdk_root}//tools/common/oad/oad_image_tool.py" + sources = [ "${root_out_dir}/${objcopy_image_name}" ] + outputs = [ "${root_out_dir}/${output_base_name}.bin" ] + + args = [ + "--verbose", + "ccs", + rebase_path(root_out_dir, root_build_dir), + "7", + "-hex1", + rebase_path("${root_out_dir}/${output_base_name}.hex", root_out_dir), + "-o", + output_base_name, ] - } else { + + if (defined(invoker.pem_file)) { + args += [ + "-k", + rebase_path(invoker.pem_file, root_build_dir), + ] + } else { + args += [ + "-k", + rebase_path( + "${ti_simplelink_sdk_root}/tools/common/oad/private.pem", + root_build_dir), + ] + } + } + action("${simplelink_target_name}-bim.hex") { + public_deps = [ ":${simplelink_target_name}.bin" ] + + script = "${ti_simplelink_sdk_build_root}/oad_merge_tool.py" + sources = [ "${root_out_dir}/${output_base_name}.bin" ] + outputs = [ "${root_out_dir}/${output_base_name}-bim.hex" ] + + if (defined(invoker.bim_hex)) { + bim_hex = invoker.bim_hex + } else { + bim_hex = "${ti_simplelink_sdk_root}/examples/nortos/${ti_simplelink_board}/bim/hexfiles/bim_offchip/Release/bim_offchip.hex" + } + + args = [ + rebase_path("${root_out_dir}/${output_base_name}.bin", + root_build_dir), + rebase_path(bim_hex, root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}-bim.hex", + root_build_dir), + ] + } + pw_python_action("${target_name}.ota") { + public_deps = [ ":${simplelink_target_name}.bin" ] + + script = "${chip_root}/src/app/ota_image_tool.py" + sources = [ "${root_out_dir}/${output_base_name}.bin" ] + outputs = [ "${root_out_dir}/${output_base_name}.ota" ] + + args = [ + "create", + rebase_path("${root_out_dir}/${output_base_name}.bin", + root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}.ota", + root_build_dir), + ] + args += [ - "-k", - rebase_path("${ti_simplelink_sdk_root}/tools/common/oad/private.pem", + "-v", + matter_device_vid, + "-p", + matter_device_pid, + "-vn", + matter_software_ver, + "-vs", + matter_software_ver_str, + ] + if (defined(invoker.ota_digest)) { + args += [ + "-da", + matter_ota_digest, + ] + } else { + args += [ + "-da", + "sha256", + ] + } + if (defined(invoker.ota_args)) { + args += invoker.ota_args + } + } + } else if (ti_simplelink_device_family == "cc13x4_26x4") { + # add MCUBoot Header to the executable + action("${simplelink_target_name}_header.hex") { + public_deps = [ ":${simplelink_target_name}.out.image" ] + + script = "${ti_simplelink_sdk_root}/source/third_party/mcuboot/scripts/imgtool.py" + sources = [ "${root_out_dir}/${output_base_name}.hex" ] + outputs = [ "${root_out_dir}/${output_base_name}_header.hex" ] + + args = [ + "sign", + "--header-size", + "0x80", + "--align", + "4", + "--slot-size", + "0x000F6000", # must match the flash_map_backend definitions + "--version", + matter_software_ver_str, + "--pad-header", + "--pad", + "--key", + rebase_path( + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/root-ec-p256.pem", + root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}.hex", root_out_dir), + rebase_path("${root_out_dir}/${output_base_name}_header.hex", + root_out_dir), + ] + } + action("${simplelink_target_name}_header.bin") { + inputs = [ "${root_out_dir}/${output_base_name}_header.hex" ] + outputs = [ "${root_out_dir}/${output_base_name}_header.bin" ] + deps = [ ":${simplelink_target_name}_header.hex" ] + args = [ + objcopy, + "-I", + "ihex", + "-O", + "binary", + rebase_path("${root_out_dir}/${output_base_name}_header.hex", + root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}_header.bin", root_build_dir), ] + script = "${build_root}/gn_run_binary.py" } - } - pw_python_action("${simplelink_target_name}-bim.hex") { - public_deps = [ ":${simplelink_target_name}.bin" ] - script = "${ti_simplelink_sdk_build_root}/oad_merge_tool.py" - sources = [ "${root_out_dir}/${output_base_name}.bin" ] - outputs = [ "${root_out_dir}/${output_base_name}-bim.hex" ] + # Generate MCUBoot sysconfig + ti_sysconfig("${simplelink_target_name}_mcuboot.syscfg") { + sources = [ "${ti_simplelink_sdk_build_root}/mcuboot/mcuboot.syscfg" ] + rtos = "nortos" + outputs = [ + "ti_drivers_config.c", + "ti_drivers_config.h", + "ti_devices_config.c", + "ti_devices_config.h", - if (defined(invoker.bim_hex)) { - bim_hex = invoker.bim_hex - } else { - bim_hex = "${ti_simplelink_sdk_root}/examples/nortos/${ti_simplelink_board}/bim/hexfiles/bim_offchip/Release/bim_offchip.hex" + # not traditional source files + #"ti_utils_build_linker.cmd.genlibs", + #"syscfg_c.rov.xs", + ] } - args = [ - rebase_path("${root_out_dir}/${output_base_name}.bin", root_build_dir), - rebase_path(bim_hex, root_build_dir), - rebase_path("${root_out_dir}/${output_base_name}-bim.hex", - root_build_dir), - ] + # build MCUBoot bootloader + config("${simplelink_target_name}_mcubootloader_config") { + libs = [ "${ti_simplelink_sdk_root}/source/ti/devices/cc13x4_cc26x4/driverlib/bin/gcc/driverlib.lib" ] + } + flashable_executable("${simplelink_target_name}_mcubootloader") { + output_name = "${output_base_name}.mcubootloader.out" + output_dir = root_out_dir + deps = [ ":${simplelink_target_name}_mcuboot.syscfg" ] + public_configs = [ ":${simplelink_target_name}_mcubootloader_config" ] + ldscript = + "${ti_simplelink_sdk_build_root}/mcuboot/mcuboot_cc13x4_cc26x4.lds" + objcopy_image_name = "${output_base_name}.mcubootloader.hex" + objcopy_image_format = "ihex" + inputs = [ ldscript ] + sources = [ + "${ti_simplelink_sdk_build_root}/mcuboot/flash_map_backend.c", + "${ti_simplelink_sdk_build_root}/mcuboot/mcuboot_config/mcuboot_config.h", + "${ti_simplelink_sdk_build_root}/syscalls_stubs.cpp", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/boot_record.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/bootutil_misc.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/bootutil_public.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/caps.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/encrypted.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/fault_injection_hardening.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/fault_injection_hardening_delay_rng_mbedtls.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/image_ec.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/image_ec256.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/image_ed25519.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/image_rsa.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/image_validate.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/loader.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/swap_misc.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/swap_move.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/swap_priv.h", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/swap_scratch.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src/tlv.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/ti/source/mcuboot_app/keys.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/ti/source/mcuboot_app/mcuboot_app.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/ti/source/mcuboot_app/security_cnt.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/ext/mbedtls-asn1/src/asn1parse.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/ext/mbedtls-asn1/src/platform_util.c", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/ext/ti-crypto/sl_crypto.c", + "${ti_simplelink_sdk_root}/source/ti/common/cc26xx/debug/led_debug.c", + "${ti_simplelink_sdk_root}/source/ti/common/cc26xx/ecc/ECDSACC26X4_driverlib.c", + "${ti_simplelink_sdk_root}/source/ti/common/cc26xx/sha2/sha2_driverlib.c", + "${ti_simplelink_sdk_root}/source/ti/common/flash/no_rtos/extFlash/bsp_spi_cc13x4_cc26x4.c", + "${ti_simplelink_sdk_root}/source/ti/common/flash/no_rtos/extFlash/ext_flash.c", + "${ti_simplelink_sdk_root}/source/ti/common/mcuboot/boot_seed/boot_seed_cc13x4_cc26x4.c", + ] - args += [ "${root_out_dir}/${output_base_name}-bim.hex" ] - } - pw_python_action("${target_name}.ota") { - public_deps = [ ":${simplelink_target_name}-bim.hex" ] - - script = "${chip_root}/src/app/ota_image_tool.py" - sources = [ "${root_out_dir}/${output_base_name}.bin" ] - outputs = [ "${root_out_dir}/${output_base_name}.ota" ] - - args = [ - "create", - rebase_path("${root_out_dir}/${output_base_name}.bin", root_build_dir), - rebase_path("${root_out_dir}/${output_base_name}.ota", root_build_dir), - ] - - args += [ - "-v", - matter_device_vid, - "-p", - matter_device_pid, - "-vn", - matter_software_ver, - "-vs", - matter_software_ver_str, - ] - if (defined(invoker.ota_digest)) { - args += [ - "-da", - matter_ota_digest, + include_dirs = [ + # === MUST BE BEFORE === + # "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/ti/source/mcuboot_app" + # to eclipse the mcuboot config header + "${ti_simplelink_sdk_build_root}/mcuboot", + + "${ti_simplelink_sdk_root}/kernel/nortos", + "${ti_simplelink_sdk_root}/source", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/include", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/bootutil/src", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/boot/ti/source/mcuboot_app", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/ext", + "${ti_simplelink_sdk_root}/source/third_party/mcuboot/ext/mbedtls-asn1/include", + "${ti_simplelink_sdk_root}/source/ti", + "${ti_simplelink_sdk_root}/source/ti/common/cc26xx/ecc", + "${ti_simplelink_sdk_root}/source/ti/common/cc26xx/sha2", + "${ti_simplelink_sdk_root}/source/ti/common/flash/no_rtos/extFlash", ] - } else { - args += [ - "-da", - "sha256", + + defines = [ + "EXCLUDE_TRACE", + "BOOT_LOADER", + ] + + ldflags = [ + "-eresetISR", + "-L" + + rebase_path(ti_simplelink_sdk_root + "/source", root_build_dir), + "-L" + rebase_path(ti_simplelink_sdk_root + "/kernel/nortos", + root_build_dir), + rebase_path( + "${target_gen_dir}/${simplelink_target_name}_mcuboot.syscfg/ti_utils_build_linker.cmd.genlibs", + root_build_dir), + "-T" + rebase_path(ldscript, root_build_dir), ] } - if (defined(invoker.ota_args)) { - args += invoker.ota_args + + action("${simplelink_target_name}-mcuboot.hex") { + public_deps = [ + ":${simplelink_target_name}_header.bin", + ":${simplelink_target_name}_mcubootloader.image", + ] + + script = "${ti_simplelink_sdk_build_root}/oad_merge_tool.py" + sources = [ + "${root_out_dir}/${output_base_name}.mcubootloader.hex", + "${root_out_dir}/${output_base_name}_header.bin", + ] + outputs = [ "${root_out_dir}/${output_base_name}-mcuboot.hex" ] + + args = [ + rebase_path("${root_out_dir}/${output_base_name}_header.hex", + root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}.mcubootloader.hex", + root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}-mcuboot.hex", + root_build_dir), + ] + } + pw_python_action("${target_name}.ota") { + # For MCUBoot the image could be truncated to the actual executable + # size. The hex file is padded to the slot size. + public_deps = [ ":${simplelink_target_name}_header.bin" ] + + script = "${chip_root}/src/app/ota_image_tool.py" + sources = [ "${root_out_dir}/${output_base_name}_header.bin" ] + outputs = [ "${root_out_dir}/${output_base_name}.ota" ] + + args = [ + "create", + rebase_path("${root_out_dir}/${output_base_name}_header.bin", + root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}.ota", + root_build_dir), + ] + + args += [ + "-v", + matter_device_vid, + "-p", + matter_device_pid, + "-vn", + matter_software_ver, + "-vs", + matter_software_ver_str, + ] + if (defined(invoker.ota_digest)) { + args += [ + "-da", + matter_ota_digest, + ] + } else { + args += [ + "-da", + "sha256", + ] + } + if (defined(invoker.ota_args)) { + args += invoker.ota_args + } } } } group(simplelink_target_name) { - data_deps = [ ":$final_target" ] + if (chip_enable_ota_requestor) { + # Generating the ota binary image + if (ti_simplelink_device_family == "cc13x2x7_26x2x7") { + data_deps = [ + ":${simplelink_target_name}-bim.hex", + ":${simplelink_target_name}.ota", + ":${simplelink_target_name}.out", + ] + } else if (ti_simplelink_device_family == "cc13x4_26x4") { + data_deps = [ + ":${simplelink_target_name}-mcuboot.hex", + ":${simplelink_target_name}.ota", + ":${simplelink_target_name}.out", + ] + } + } else { + # The executable is the final target. + data_deps = [ ":${simplelink_target_name}.out" ] + } if (defined(invoker.data_deps)) { data_deps += invoker.data_deps diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni index ee16f5179e5859..8a8cfd71247598 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni @@ -112,6 +112,12 @@ template("ti_sysconfig") { sources = invoker.sources outputs = gen_outputs + if (defined(invoker.rtos)) { + rtos = invoker.rtos + } else { + rtos = "freertos" + } + if (ti_simplelink_device == "") { args = [ ti_sysconfig_root, @@ -125,7 +131,7 @@ template("ti_sysconfig") { "--board", "/ti/boards/" + ti_simplelink_board, "--rtos", - "freertos", + rtos, ] } else { args = [ @@ -140,7 +146,7 @@ template("ti_sysconfig") { "--device", ti_simplelink_device, "--rtos", - "freertos", + rtos, ] } 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 8a37b3770fe22c..66f3ff69bb6949 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 @@ -10130,6 +10130,74 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) } // namespace Attributes } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +namespace Attributes { + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ElectricalEnergyMeasurement::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, uint32_t 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::ElectricalEnergyMeasurement::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); +} + +} // namespace FeatureMap + +namespace ClusterRevision { + +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ElectricalEnergyMeasurement::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) +{ + 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::ElectricalEnergyMeasurement::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); +} + +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace ElectricalEnergyMeasurement + namespace DemandResponseLoadControl { namespace Attributes { 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 616148bb9327fa..4222d40ea76f9f 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 @@ -1961,6 +1961,22 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); } // namespace Attributes } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +namespace Attributes { + +namespace FeatureMap { +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); +} // namespace FeatureMap + +namespace ClusterRevision { +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace ElectricalEnergyMeasurement + namespace DemandResponseLoadControl { namespace Attributes { 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 858328342defbb..ff5751ddcb52ee 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -553,6 +553,14 @@ void emberAfBooleanSensorConfigurationClusterInitCallback(chip::EndpointId endpo */ void emberAfValveConfigurationAndControlClusterInitCallback(chip::EndpointId endpoint); +/** @brief Electrical Energy Measurement Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalEnergyMeasurementClusterInitCallback(chip::EndpointId endpoint); + /** @brief Demand Response Load Control Cluster Init * * Cluster Init @@ -5937,6 +5945,82 @@ void emberAfValveConfigurationAndControlClusterServerTickCallback(chip::Endpoint */ void emberAfValveConfigurationAndControlClusterClientTickCallback(chip::EndpointId endpoint); +// +// Electrical Energy Measurement Cluster +// + +/** @brief Electrical Energy Measurement Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalEnergyMeasurementClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Electrical Energy Measurement Cluster Server Shutdown + * + * Server Shutdown + * + * @param endpoint Endpoint that is being shutdown + */ +void MatterElectricalEnergyMeasurementClusterServerShutdownCallback(chip::EndpointId endpoint); + +/** @brief Electrical Energy Measurement Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalEnergyMeasurementClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Electrical Energy Measurement Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param attributePath Concrete attribute path that changed + */ +void MatterElectricalEnergyMeasurementClusterServerAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); + +/** @brief Electrical Energy Measurement Cluster Server Pre Attribute Changed + * + * Server Pre Attribute Changed + * + * @param attributePath Concrete attribute path to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +chip::Protocols::InteractionModel::Status MatterElectricalEnergyMeasurementClusterServerPreAttributeChangedCallback( + const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); + +/** @brief Electrical Energy Measurement Cluster Client Pre Attribute Changed + * + * Client Pre Attribute Changed + * + * @param attributePath Concrete attribute path to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +chip::Protocols::InteractionModel::Status MatterElectricalEnergyMeasurementClusterClientPreAttributeChangedCallback( + const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); + +/** @brief Electrical Energy Measurement Cluster Server Tick + * + * Server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfElectricalEnergyMeasurementClusterServerTickCallback(chip::EndpointId endpoint); + +/** @brief Electrical Energy Measurement Cluster Client Tick + * + * Client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfElectricalEnergyMeasurementClusterClientTickCallback(chip::EndpointId endpoint); + // // Demand Response Load Control Cluster // 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 7ef15603b1df39..48a2a5094ad527 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 @@ -1535,6 +1535,32 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndCo } } +static auto __attribute__((unused)) EnsureKnownEnumValue(ElectricalEnergyMeasurement::MeasurementTypeEnum val) +{ + using EnumType = ElectricalEnergyMeasurement::MeasurementTypeEnum; + switch (val) + { + case EnumType::kUnspecified: + case EnumType::kVoltage: + case EnumType::kActiveCurrent: + case EnumType::kReactiveCurrent: + case EnumType::kApparentCurrent: + case EnumType::kActivePower: + case EnumType::kReactivePower: + case EnumType::kApparentPower: + case EnumType::kRMSVoltage: + case EnumType::kRMSCurrent: + case EnumType::kRMSPower: + case EnumType::kFrequency: + case EnumType::kPowerFactor: + case EnumType::kNeutralCurrent: + case EnumType::kElectricalEnergy: + return val; + default: + return static_cast(15); + } +} + static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::CriticalityLevelEnum val) { using EnumType = DemandResponseLoadControl::CriticalityLevelEnum; 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 bd815d7b2bdebe..adcca6f89087af 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 @@ -2187,6 +2187,43 @@ enum class ValveFaultBitmap : uint16_t }; } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { + +// Enum for MeasurementTypeEnum +enum class MeasurementTypeEnum : uint16_t +{ + kUnspecified = 0x00, + kVoltage = 0x01, + kActiveCurrent = 0x02, + kReactiveCurrent = 0x03, + kApparentCurrent = 0x04, + kActivePower = 0x05, + kReactivePower = 0x06, + kApparentPower = 0x07, + kRMSVoltage = 0x08, + kRMSCurrent = 0x09, + kRMSPower = 0x0A, + kFrequency = 0x0B, + kPowerFactor = 0x0C, + kNeutralCurrent = 0x0D, + kElectricalEnergy = 0x0E, + // 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 = 15, +}; + +// Bitmap for Feature +enum class Feature : uint32_t +{ + kImportedEnergy = 0x1, + kExportedEnergy = 0x2, + kCumulativeEnergy = 0x4, + kPeriodicEnergy = 0x8, +}; +} // namespace ElectricalEnergyMeasurement + namespace DemandResponseLoadControl { // Enum for CriticalityLevelEnum 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 56efe1d5e0bc3e..df15ba3324775f 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 @@ -13999,6 +13999,312 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace Events } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +namespace Structs { + +namespace MeasurementAccuracyRangeStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kRangeMin), rangeMin); + encoder.Encode(to_underlying(Fields::kRangeMax), rangeMax); + encoder.Encode(to_underlying(Fields::kPercentMax), percentMax); + encoder.Encode(to_underlying(Fields::kPercentMin), percentMin); + encoder.Encode(to_underlying(Fields::kPercentTypical), percentTypical); + encoder.Encode(to_underlying(Fields::kFixedMax), fixedMax); + encoder.Encode(to_underlying(Fields::kFixedMin), fixedMin); + encoder.Encode(to_underlying(Fields::kFixedTypical), fixedTypical); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kRangeMin)) + { + err = DataModel::Decode(reader, rangeMin); + } + else if (__context_tag == to_underlying(Fields::kRangeMax)) + { + err = DataModel::Decode(reader, rangeMax); + } + else if (__context_tag == to_underlying(Fields::kPercentMax)) + { + err = DataModel::Decode(reader, percentMax); + } + else if (__context_tag == to_underlying(Fields::kPercentMin)) + { + err = DataModel::Decode(reader, percentMin); + } + else if (__context_tag == to_underlying(Fields::kPercentTypical)) + { + err = DataModel::Decode(reader, percentTypical); + } + else if (__context_tag == to_underlying(Fields::kFixedMax)) + { + err = DataModel::Decode(reader, fixedMax); + } + else if (__context_tag == to_underlying(Fields::kFixedMin)) + { + err = DataModel::Decode(reader, fixedMin); + } + else if (__context_tag == to_underlying(Fields::kFixedTypical)) + { + err = DataModel::Decode(reader, fixedTypical); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace MeasurementAccuracyRangeStruct + +namespace MeasurementAccuracyStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kMeasurementType), measurementType); + encoder.Encode(to_underlying(Fields::kMeasured), measured); + encoder.Encode(to_underlying(Fields::kMinMeasuredValue), minMeasuredValue); + encoder.Encode(to_underlying(Fields::kMaxMeasuredValue), maxMeasuredValue); + encoder.Encode(to_underlying(Fields::kAccuracyRanges), accuracyRanges); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kMeasurementType)) + { + err = DataModel::Decode(reader, measurementType); + } + else if (__context_tag == to_underlying(Fields::kMeasured)) + { + err = DataModel::Decode(reader, measured); + } + else if (__context_tag == to_underlying(Fields::kMinMeasuredValue)) + { + err = DataModel::Decode(reader, minMeasuredValue); + } + else if (__context_tag == to_underlying(Fields::kMaxMeasuredValue)) + { + err = DataModel::Decode(reader, maxMeasuredValue); + } + else if (__context_tag == to_underlying(Fields::kAccuracyRanges)) + { + err = DataModel::Decode(reader, accuracyRanges); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace MeasurementAccuracyStruct + +namespace EnergyMeasurementStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kEnergy), energy); + encoder.Encode(to_underlying(Fields::kStartTimestamp), startTimestamp); + encoder.Encode(to_underlying(Fields::kEndTimestamp), endTimestamp); + encoder.Encode(to_underlying(Fields::kStartSystime), startSystime); + encoder.Encode(to_underlying(Fields::kEndSystime), endSystime); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kEnergy)) + { + err = DataModel::Decode(reader, energy); + } + else if (__context_tag == to_underlying(Fields::kStartTimestamp)) + { + err = DataModel::Decode(reader, startTimestamp); + } + else if (__context_tag == to_underlying(Fields::kEndTimestamp)) + { + err = DataModel::Decode(reader, endTimestamp); + } + else if (__context_tag == to_underlying(Fields::kStartSystime)) + { + err = DataModel::Decode(reader, startSystime); + } + else if (__context_tag == to_underlying(Fields::kEndSystime)) + { + err = DataModel::Decode(reader, endSystime); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace EnergyMeasurementStruct +} // namespace Structs + +namespace Commands {} // namespace Commands + +namespace Attributes { +CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path) +{ + switch (path.mAttributeId) + { + case Attributes::Accuracy::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, accuracy); + case Attributes::CumulativeEnergyImported::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, cumulativeEnergyImported); + case Attributes::CumulativeEnergyExported::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, cumulativeEnergyExported); + case Attributes::PeriodicEnergyImported::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, periodicEnergyImported); + case Attributes::PeriodicEnergyExported::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, periodicEnergyExported); + case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, generatedCommandList); + case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, acceptedCommandList); + case Attributes::EventList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, eventList); + case Attributes::AttributeList::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, attributeList); + case Attributes::FeatureMap::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, featureMap); + case Attributes::ClusterRevision::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, clusterRevision); + default: + return CHIP_NO_ERROR; + } +} +} // namespace Attributes + +namespace Events { +namespace CumulativeEnergyMeasured { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(aWriter.StartContainer(aTag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kEnergyImported), energyImported)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kEnergyExported), energyExported)); + return aWriter.EndContainer(outer); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kEnergyImported)) + { + err = DataModel::Decode(reader, energyImported); + } + else if (__context_tag == to_underlying(Fields::kEnergyExported)) + { + err = DataModel::Decode(reader, energyExported); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace CumulativeEnergyMeasured. +namespace PeriodicEnergyMeasured { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(aWriter.StartContainer(aTag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kEnergyImported), energyImported)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kEnergyExported), energyExported)); + return aWriter.EndContainer(outer); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kEnergyImported)) + { + err = DataModel::Decode(reader, energyImported); + } + else if (__context_tag == to_underlying(Fields::kEnergyExported)) + { + err = DataModel::Decode(reader, energyExported); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace PeriodicEnergyMeasured. +} // namespace Events + +} // namespace ElectricalEnergyMeasurement namespace DemandResponseLoadControl { namespace Structs { @@ -27640,7 +27946,48 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre } } // namespace Attributes -namespace Events {} // namespace Events +namespace Events { +namespace PingCountEvent { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(aWriter.StartContainer(aTag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kCount), count)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kFabricIndex), fabricIndex)); + return aWriter.EndContainer(outer); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kCount)) + { + err = DataModel::Decode(reader, count); + } + else if (__context_tag == to_underlying(Fields::kFabricIndex)) + { + err = DataModel::Decode(reader, fabricIndex); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace PingCountEvent. +} // namespace Events } // namespace SampleMei 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 421dad0af3e981..753e52108eb6a5 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 @@ -20112,6 +20112,322 @@ struct DecodableType } // namespace ValveFault } // namespace Events } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +namespace Structs { +namespace MeasurementAccuracyRangeStruct { +enum class Fields : uint8_t +{ + kRangeMin = 0, + kRangeMax = 1, + kPercentMax = 2, + kPercentMin = 3, + kPercentTypical = 4, + kFixedMax = 5, + kFixedMin = 6, + kFixedTypical = 7, +}; + +struct Type +{ +public: + int64_t rangeMin = static_cast(0); + int64_t rangeMax = static_cast(0); + Optional percentMax; + Optional percentMin; + Optional percentTypical; + Optional fixedMax; + Optional fixedMin; + Optional fixedTypical; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +using DecodableType = Type; + +} // namespace MeasurementAccuracyRangeStruct +namespace MeasurementAccuracyStruct { +enum class Fields : uint8_t +{ + kMeasurementType = 0, + kMeasured = 1, + kMinMeasuredValue = 2, + kMaxMeasuredValue = 3, + kAccuracyRanges = 4, +}; + +struct Type +{ +public: + MeasurementTypeEnum measurementType = static_cast(0); + bool measured = static_cast(0); + int64_t minMeasuredValue = static_cast(0); + int64_t maxMeasuredValue = static_cast(0); + DataModel::List accuracyRanges; + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + MeasurementTypeEnum measurementType = static_cast(0); + bool measured = static_cast(0); + int64_t minMeasuredValue = static_cast(0); + int64_t maxMeasuredValue = static_cast(0); + DataModel::DecodableList accuracyRanges; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; +}; + +} // namespace MeasurementAccuracyStruct +namespace EnergyMeasurementStruct { +enum class Fields : uint8_t +{ + kEnergy = 0, + kStartTimestamp = 1, + kEndTimestamp = 2, + kStartSystime = 3, + kEndSystime = 4, +}; + +struct Type +{ +public: + int64_t energy = static_cast(0); + Optional startTimestamp; + Optional endTimestamp; + Optional startSystime; + Optional endSystime; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +using DecodableType = Type; + +} // namespace EnergyMeasurementStruct +} // namespace Structs + +namespace Attributes { + +namespace Accuracy { +struct TypeInfo +{ + using Type = chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type; + using DecodableType = chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType; + using DecodableArgType = + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::Accuracy::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace Accuracy +namespace CumulativeEnergyImported { +struct TypeInfo +{ + using Type = + chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::CumulativeEnergyImported::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace CumulativeEnergyImported +namespace CumulativeEnergyExported { +struct TypeInfo +{ + using Type = + chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::CumulativeEnergyExported::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace CumulativeEnergyExported +namespace PeriodicEnergyImported { +struct TypeInfo +{ + using Type = + chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::PeriodicEnergyImported::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace PeriodicEnergyImported +namespace PeriodicEnergyExported { +struct TypeInfo +{ + using Type = + chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> &; + + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::PeriodicEnergyExported::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace PeriodicEnergyExported +namespace GeneratedCommandList { +struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } +}; +} // namespace GeneratedCommandList +namespace AcceptedCommandList { +struct TypeInfo : public Clusters::Globals::Attributes::AcceptedCommandList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } +}; +} // namespace AcceptedCommandList +namespace EventList { +struct TypeInfo : public Clusters::Globals::Attributes::EventList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } +}; +} // namespace EventList +namespace AttributeList { +struct TypeInfo : public Clusters::Globals::Attributes::AttributeList::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } +}; +} // namespace AttributeList +namespace FeatureMap { +struct TypeInfo : public Clusters::Globals::Attributes::FeatureMap::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } +}; +} // namespace FeatureMap +namespace ClusterRevision { +struct TypeInfo : public Clusters::Globals::Attributes::ClusterRevision::TypeInfo +{ + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } +}; +} // namespace ClusterRevision + +struct TypeInfo +{ + struct DecodableType + { + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); + + Attributes::Accuracy::TypeInfo::DecodableType accuracy; + Attributes::CumulativeEnergyImported::TypeInfo::DecodableType cumulativeEnergyImported; + Attributes::CumulativeEnergyExported::TypeInfo::DecodableType cumulativeEnergyExported; + Attributes::PeriodicEnergyImported::TypeInfo::DecodableType periodicEnergyImported; + Attributes::PeriodicEnergyExported::TypeInfo::DecodableType periodicEnergyExported; + Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; + Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; + Attributes::EventList::TypeInfo::DecodableType eventList; + Attributes::AttributeList::TypeInfo::DecodableType attributeList; + Attributes::FeatureMap::TypeInfo::DecodableType featureMap = static_cast(0); + Attributes::ClusterRevision::TypeInfo::DecodableType clusterRevision = static_cast(0); + }; +}; +} // namespace Attributes +namespace Events { +namespace CumulativeEnergyMeasured { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kEnergyImported = 0, + kEnergyExported = 1, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::CumulativeEnergyMeasured::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr bool kIsFabricScoped = false; + + Optional energyImported; + Optional energyExported; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::CumulativeEnergyMeasured::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + + Optional energyImported; + Optional energyExported; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace CumulativeEnergyMeasured +namespace PeriodicEnergyMeasured { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kEnergyImported = 0, + kEnergyExported = 1, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::PeriodicEnergyMeasured::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + static constexpr bool kIsFabricScoped = false; + + Optional energyImported; + Optional energyExported; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::PeriodicEnergyMeasured::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ElectricalEnergyMeasurement::Id; } + + Optional energyImported; + Optional energyExported; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace PeriodicEnergyMeasured +} // namespace Events +} // namespace ElectricalEnergyMeasurement namespace DemandResponseLoadControl { namespace Structs { namespace HeatingSourceControlStruct { @@ -42020,6 +42336,46 @@ struct TypeInfo }; }; } // namespace Attributes +namespace Events { +namespace PingCountEvent { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kCount = 1, + kFabricIndex = 254, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::PingCountEvent::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } + static constexpr bool kIsFabricScoped = true; + + uint32_t count = static_cast(0); + chip::FabricIndex fabricIndex = static_cast(0); + + auto GetFabricIndex() const { return fabricIndex; } + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::PingCountEvent::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } + + uint32_t count = static_cast(0); + chip::FabricIndex fabricIndex = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace PingCountEvent +} // namespace Events } // namespace SampleMei } // namespace Clusters 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 505b66778784e2..732997cd74bf35 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 @@ -3629,6 +3629,56 @@ static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; } // namespace Attributes } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +namespace Attributes { + +namespace Accuracy { +static constexpr AttributeId Id = 0x00000000; +} // namespace Accuracy + +namespace CumulativeEnergyImported { +static constexpr AttributeId Id = 0x00000001; +} // namespace CumulativeEnergyImported + +namespace CumulativeEnergyExported { +static constexpr AttributeId Id = 0x00000002; +} // namespace CumulativeEnergyExported + +namespace PeriodicEnergyImported { +static constexpr AttributeId Id = 0x00000003; +} // namespace PeriodicEnergyImported + +namespace PeriodicEnergyExported { +static constexpr AttributeId Id = 0x00000004; +} // namespace PeriodicEnergyExported + +namespace GeneratedCommandList { +static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; +} // namespace GeneratedCommandList + +namespace AcceptedCommandList { +static constexpr AttributeId Id = Globals::Attributes::AcceptedCommandList::Id; +} // namespace AcceptedCommandList + +namespace EventList { +static constexpr AttributeId Id = Globals::Attributes::EventList::Id; +} // namespace EventList + +namespace AttributeList { +static constexpr AttributeId Id = Globals::Attributes::AttributeList::Id; +} // namespace AttributeList + +namespace FeatureMap { +static constexpr AttributeId Id = Globals::Attributes::FeatureMap::Id; +} // namespace FeatureMap + +namespace ClusterRevision { +static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace ElectricalEnergyMeasurement + namespace DemandResponseLoadControl { namespace Attributes { diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h b/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h index e213295cfaffdf..30795284640706 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h @@ -220,6 +220,9 @@ static constexpr ClusterId Id = 0x00000080; namespace ValveConfigurationAndControl { static constexpr ClusterId Id = 0x00000081; } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +static constexpr ClusterId Id = 0x00000091; +} // namespace ElectricalEnergyMeasurement namespace DemandResponseLoadControl { static constexpr ClusterId Id = 0x00000096; } // namespace DemandResponseLoadControl 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 38d917c669e297..f65f37b9cd13e5 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 @@ -407,6 +407,20 @@ static constexpr EventId Id = 0x00000001; } // namespace Events } // namespace ValveConfigurationAndControl +namespace ElectricalEnergyMeasurement { +namespace Events { + +namespace CumulativeEnergyMeasured { +static constexpr EventId Id = 0x00000000; +} // namespace CumulativeEnergyMeasured + +namespace PeriodicEnergyMeasured { +static constexpr EventId Id = 0x00000001; +} // namespace PeriodicEnergyMeasured + +} // namespace Events +} // namespace ElectricalEnergyMeasurement + namespace DemandResponseLoadControl { namespace Events { @@ -623,6 +637,16 @@ static constexpr EventId Id = 0x00000002; } // namespace Events } // namespace UnitTesting +namespace SampleMei { +namespace Events { + +namespace PingCountEvent { +static constexpr EventId Id = 0x00000000; +} // namespace PingCountEvent + +} // namespace Events +} // namespace SampleMei + } // namespace Clusters } // namespace app } // namespace chip diff --git a/zzz_generated/app-common/app-common/zap-generated/print-cluster.h b/zzz_generated/app-common/app-common/zap-generated/print-cluster.h index 8bf39558bca336..dce92e23194866 100644 --- a/zzz_generated/app-common/app-common/zap-generated/print-cluster.h +++ b/zzz_generated/app-common/app-common/zap-generated/print-cluster.h @@ -443,6 +443,14 @@ #define CHIP_PRINTCLUSTER_VALVE_CONFIGURATION_AND_CONTROL_CLUSTER #endif +#if defined(ZCL_USING_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_SERVER) || \ + defined(ZCL_USING_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER \ + { chip::app::Clusters::ElectricalEnergyMeasurement::Id, "Electrical Energy Measurement" }, +#else +#define CHIP_PRINTCLUSTER_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER +#endif + #if defined(ZCL_USING_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER \ { chip::app::Clusters::DemandResponseLoadControl::Id, "Demand Response Load Control" }, @@ -817,6 +825,7 @@ CHIP_PRINTCLUSTER_ACTIVATED_CARBON_FILTER_MONITORING_CLUSTER \ CHIP_PRINTCLUSTER_BOOLEAN_SENSOR_CONFIGURATION_CLUSTER \ CHIP_PRINTCLUSTER_VALVE_CONFIGURATION_AND_CONTROL_CLUSTER \ + CHIP_PRINTCLUSTER_ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_ENERGY_MANAGEMENT_CLUSTER \ CHIP_PRINTCLUSTER_ENERGY_EVSE_CLUSTER \ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index c966ee0534f603..f1020496d9781d 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -99,6 +99,7 @@ | ActivatedCarbonFilterMonitoring | 0x0072 | | BooleanSensorConfiguration | 0x0080 | | ValveConfigurationAndControl | 0x0081 | +| ElectricalEnergyMeasurement | 0x0091 | | DemandResponseLoadControl | 0x0096 | | DeviceEnergyManagement | 0x0098 | | EnergyEvse | 0x0099 | @@ -6573,6 +6574,29 @@ class ValveConfigurationAndControlSetLevel : public ClusterCommand chip::app::Clusters::ValveConfigurationAndControl::Commands::SetLevel::Type mRequest; }; +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalEnergyMeasurement | 0x0091 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * Accuracy | 0x0000 | +| * CumulativeEnergyImported | 0x0001 | +| * CumulativeEnergyExported | 0x0002 | +| * PeriodicEnergyImported | 0x0003 | +| * PeriodicEnergyExported | 0x0004 | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +| * CumulativeEnergyMeasured | 0x0000 | +| * PeriodicEnergyMeasured | 0x0001 | +\*----------------------------------------------------------------------------*/ + /*----------------------------------------------------------------------------*\ | Cluster DemandResponseLoadControl | 0x0096 | |------------------------------------------------------------------------------| @@ -13840,6 +13864,7 @@ class FaultInjectionFailRandomlyAtFault : public ClusterCommand | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * PingCountEvent | 0x0000 | \*----------------------------------------------------------------------------*/ /* @@ -19324,6 +19349,96 @@ void registerClusterValveConfigurationAndControl(Commands & commands, Credential commands.RegisterCluster(clusterName, clusterCommands); } +void registerClusterElectricalEnergyMeasurement(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) +{ + using namespace chip::app::Clusters::ElectricalEnergyMeasurement; + + const char * clusterName = "ElectricalEnergyMeasurement"; + + commands_list clusterCommands = { + // + // Commands + // + make_unique(Id, credsIssuerConfig), // + // + // Attributes + // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "accuracy", Attributes::Accuracy::Id, credsIssuerConfig), // + make_unique(Id, "cumulative-energy-imported", Attributes::CumulativeEnergyImported::Id, + credsIssuerConfig), // + make_unique(Id, "cumulative-energy-exported", Attributes::CumulativeEnergyExported::Id, + credsIssuerConfig), // + make_unique(Id, "periodic-energy-imported", Attributes::PeriodicEnergyImported::Id, credsIssuerConfig), // + make_unique(Id, "periodic-energy-exported", Attributes::PeriodicEnergyExported::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< + WriteAttributeAsComplex>( + Id, "accuracy", Attributes::Accuracy::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "cumulative-energy-imported", Attributes::CumulativeEnergyImported::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "cumulative-energy-exported", Attributes::CumulativeEnergyExported::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "periodic-energy-imported", Attributes::PeriodicEnergyImported::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "periodic-energy-exported", Attributes::PeriodicEnergyExported::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "event-list", Attributes::EventList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "attribute-list", Attributes::AttributeList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + 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, "accuracy", Attributes::Accuracy::Id, credsIssuerConfig), // + make_unique(Id, "cumulative-energy-imported", Attributes::CumulativeEnergyImported::Id, + credsIssuerConfig), // + make_unique(Id, "cumulative-energy-exported", Attributes::CumulativeEnergyExported::Id, + credsIssuerConfig), // + make_unique(Id, "periodic-energy-imported", Attributes::PeriodicEnergyImported::Id, + credsIssuerConfig), // + make_unique(Id, "periodic-energy-exported", Attributes::PeriodicEnergyExported::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, "cumulative-energy-measured", Events::CumulativeEnergyMeasured::Id, credsIssuerConfig), // + make_unique(Id, "periodic-energy-measured", Events::PeriodicEnergyMeasured::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "cumulative-energy-measured", Events::CumulativeEnergyMeasured::Id, credsIssuerConfig), // + make_unique(Id, "periodic-energy-measured", Events::PeriodicEnergyMeasured::Id, credsIssuerConfig), // + }; + + commands.RegisterCluster(clusterName, clusterCommands); +} void registerClusterDemandResponseLoadControl(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) { using namespace chip::app::Clusters::DemandResponseLoadControl; @@ -25170,8 +25285,10 @@ void registerClusterSampleMei(Commands & commands, CredentialIssuerCommands * cr // // Events // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "ping-count-event", Events::PingCountEvent::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "ping-count-event", Events::PingCountEvent::Id, credsIssuerConfig), // }; commands.RegisterCluster(clusterName, clusterCommands); @@ -25266,6 +25383,7 @@ void registerClusters(Commands & commands, CredentialIssuerCommands * credsIssue registerClusterActivatedCarbonFilterMonitoring(commands, credsIssuerConfig); registerClusterBooleanSensorConfiguration(commands, credsIssuerConfig); registerClusterValveConfigurationAndControl(commands, credsIssuerConfig); + registerClusterElectricalEnergyMeasurement(commands, credsIssuerConfig); registerClusterDemandResponseLoadControl(commands, credsIssuerConfig); registerClusterDeviceEnergyManagement(commands, credsIssuerConfig); registerClusterEnergyEvse(commands, credsIssuerConfig); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 0a6a0757b2bf82..7aeb538c962c95 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -2221,6 +2221,201 @@ void ComplexArgumentParser::Finalize( ComplexArgumentParser::Finalize(request.productIdentifierValue); } +CHIP_ERROR ComplexArgumentParser::Setup( + const char * label, chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::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("MeasurementAccuracyRangeStruct.rangeMin", "rangeMin", + value.isMember("rangeMin"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyRangeStruct.rangeMax", "rangeMax", + value.isMember("rangeMax"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rangeMin"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rangeMin, value["rangeMin"])); + valueCopy.removeMember("rangeMin"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rangeMax"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rangeMax, value["rangeMax"])); + valueCopy.removeMember("rangeMax"); + + if (value.isMember("percentMax")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentMax"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentMax, value["percentMax"])); + } + valueCopy.removeMember("percentMax"); + + if (value.isMember("percentMin")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentMin"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentMin, value["percentMin"])); + } + valueCopy.removeMember("percentMin"); + + if (value.isMember("percentTypical")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "percentTypical"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.percentTypical, value["percentTypical"])); + } + valueCopy.removeMember("percentTypical"); + + if (value.isMember("fixedMax")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedMax"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedMax, value["fixedMax"])); + } + valueCopy.removeMember("fixedMax"); + + if (value.isMember("fixedMin")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedMin"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedMin, value["fixedMin"])); + } + valueCopy.removeMember("fixedMin"); + + if (value.isMember("fixedTypical")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fixedTypical"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fixedTypical, value["fixedTypical"])); + } + valueCopy.removeMember("fixedTypical"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize( + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.rangeMin); + ComplexArgumentParser::Finalize(request.rangeMax); + ComplexArgumentParser::Finalize(request.percentMax); + ComplexArgumentParser::Finalize(request.percentMin); + ComplexArgumentParser::Finalize(request.percentTypical); + ComplexArgumentParser::Finalize(request.fixedMax); + ComplexArgumentParser::Finalize(request.fixedMin); + ComplexArgumentParser::Finalize(request.fixedTypical); +} + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::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("MeasurementAccuracyStruct.measurementType", "measurementType", + value.isMember("measurementType"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.measured", "measured", value.isMember("measured"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.minMeasuredValue", "minMeasuredValue", + value.isMember("minMeasuredValue"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.maxMeasuredValue", "maxMeasuredValue", + value.isMember("maxMeasuredValue"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MeasurementAccuracyStruct.accuracyRanges", "accuracyRanges", + value.isMember("accuracyRanges"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measurementType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measurementType, value["measurementType"])); + valueCopy.removeMember("measurementType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "measured"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.measured, value["measured"])); + valueCopy.removeMember("measured"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minMeasuredValue"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minMeasuredValue, value["minMeasuredValue"])); + valueCopy.removeMember("minMeasuredValue"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxMeasuredValue"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxMeasuredValue, value["maxMeasuredValue"])); + valueCopy.removeMember("maxMeasuredValue"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "accuracyRanges"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.accuracyRanges, value["accuracyRanges"])); + valueCopy.removeMember("accuracyRanges"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize( + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.measurementType); + ComplexArgumentParser::Finalize(request.measured); + ComplexArgumentParser::Finalize(request.minMeasuredValue); + ComplexArgumentParser::Finalize(request.maxMeasuredValue); + ComplexArgumentParser::Finalize(request.accuracyRanges); +} + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::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("EnergyMeasurementStruct.energy", "energy", value.isMember("energy"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "energy"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.energy, value["energy"])); + valueCopy.removeMember("energy"); + + if (value.isMember("startTimestamp")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "startTimestamp"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.startTimestamp, value["startTimestamp"])); + } + valueCopy.removeMember("startTimestamp"); + + if (value.isMember("endTimestamp")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endTimestamp"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endTimestamp, value["endTimestamp"])); + } + valueCopy.removeMember("endTimestamp"); + + if (value.isMember("startSystime")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "startSystime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.startSystime, value["startSystime"])); + } + valueCopy.removeMember("startSystime"); + + if (value.isMember("endSystime")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endSystime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endSystime, value["endSystime"])); + } + valueCopy.removeMember("endSystime"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize( + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.energy); + ComplexArgumentParser::Finalize(request.startTimestamp); + ComplexArgumentParser::Finalize(request.endTimestamp); + ComplexArgumentParser::Finalize(request.startSystime); + ComplexArgumentParser::Finalize(request.endSystime); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::DemandResponseLoadControl::Structs::HeatingSourceControlStruct::Type & request, diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 8c5b30bd425cd8..c7affea5f68209 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -276,6 +276,24 @@ static CHIP_ERROR Setup(const char * label, static void Finalize(chip::app::Clusters::ActivatedCarbonFilterMonitoring::Structs::ReplacementProductStruct::Type & request); +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::DemandResponseLoadControl::Structs::HeatingSourceControlStruct::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 f6e11f2ac60c10..4ae5691c8c8c33 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -1985,6 +1985,180 @@ CHIP_ERROR DataModelLogger::LogValue( return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("RangeMin", indent + 1, value.rangeMin); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RangeMin'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("RangeMax", indent + 1, value.rangeMax); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RangeMax'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PercentMax", indent + 1, value.percentMax); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentMax'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PercentMin", indent + 1, value.percentMin); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentMin'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PercentTypical", indent + 1, value.percentTypical); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PercentTypical'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FixedMax", indent + 1, value.fixedMax); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedMax'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FixedMin", indent + 1, value.fixedMin); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedMin'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FixedTypical", indent + 1, value.fixedTypical); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FixedTypical'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("MeasurementType", indent + 1, value.measurementType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeasurementType'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Measured", indent + 1, value.measured); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Measured'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MinMeasuredValue", indent + 1, value.minMeasuredValue); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinMeasuredValue'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MaxMeasuredValue", indent + 1, value.maxMeasuredValue); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxMeasuredValue'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("AccuracyRanges", indent + 1, value.accuracyRanges); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AccuracyRanges'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Energy", indent + 1, value.energy); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Energy'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("StartTimestamp", indent + 1, value.startTimestamp); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StartTimestamp'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("EndTimestamp", indent + 1, value.endTimestamp); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndTimestamp'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("StartSystime", indent + 1, value.startSystime); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StartSystime'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("EndSystime", indent + 1, value.endSystime); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndSystime'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + CHIP_ERROR DataModelLogger::LogValue( const char * label, size_t indent, const chip::app::Clusters::DemandResponseLoadControl::Structs::HeatingSourceControlStruct::DecodableType & value) @@ -5370,6 +5544,54 @@ 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 ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("EnergyImported", indent + 1, value.energyImported); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'EnergyImported'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("EnergyExported", indent + 1, value.energyExported); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'EnergyExported'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const ElectricalEnergyMeasurement::Events::PeriodicEnergyMeasured::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("EnergyImported", indent + 1, value.energyImported); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'EnergyImported'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("EnergyExported", indent + 1, value.energyExported); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'EnergyExported'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const DemandResponseLoadControl::Events::LoadControlEventStatusChange::DecodableType & value) { @@ -6263,6 +6485,30 @@ 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 SampleMei::Events::PingCountEvent::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Count", indent + 1, value.count); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Count'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'FabricIndex'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const Groups::Commands::AddGroupResponse::DecodableType & value) @@ -11446,6 +11692,75 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP } break; } + case ElectricalEnergyMeasurement::Id: { + switch (path.mAttributeId) + { + case ElectricalEnergyMeasurement::Attributes::Accuracy::Id: { + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Accuracy", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::CumulativeEnergyImported::Id: { + chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("CumulativeEnergyImported", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::CumulativeEnergyExported::Id: { + chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("CumulativeEnergyExported", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::PeriodicEnergyImported::Id: { + chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PeriodicEnergyImported", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::PeriodicEnergyExported::Id: { + chip::app::DataModel::Nullable< + chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PeriodicEnergyExported", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("GeneratedCommandList", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::AcceptedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AcceptedCommandList", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::EventList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("EventList", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::AttributeList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AttributeList", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::FeatureMap::Id: { + uint32_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("FeatureMap", 1, value); + } + case ElectricalEnergyMeasurement::Attributes::ClusterRevision::Id: { + uint16_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ClusterRevision", 1, value); + } + } + break; + } case DemandResponseLoadControl::Id: { switch (path.mAttributeId) { @@ -17513,6 +17828,22 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case ElectricalEnergyMeasurement::Id: { + switch (header.mPath.mEventId) + { + case ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::Id: { + chip::app::Clusters::ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("CumulativeEnergyMeasured", 1, value); + } + case ElectricalEnergyMeasurement::Events::PeriodicEnergyMeasured::Id: { + chip::app::Clusters::ElectricalEnergyMeasurement::Events::PeriodicEnergyMeasured::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PeriodicEnergyMeasured", 1, value); + } + } + break; + } case DemandResponseLoadControl::Id: { switch (header.mPath.mEventId) { @@ -17768,6 +18099,17 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case SampleMei::Id: { + switch (header.mPath.mEventId) + { + case SampleMei::Events::PingCountEvent::Id: { + chip::app::Clusters::SampleMei::Events::PingCountEvent::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PingCountEvent", 1, value); + } + } + break; + } default: break; } 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 ac9d4a8a4ccd5b..c208cac4302149 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -173,6 +173,18 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ActivatedCarbonFilterMonitoring::Structs::ReplacementProductStruct::DecodableType & value); +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Structs::EnergyMeasurementStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DemandResponseLoadControl::Structs::HeatingSourceControlStruct::DecodableType & value); @@ -461,6 +473,12 @@ LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ValveConfigurationAndControl::Events::ValveFault::DecodableType & value); static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::DecodableType & value); +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ElectricalEnergyMeasurement::Events::PeriodicEnergyMeasured::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DemandResponseLoadControl::Events::LoadControlEventStatusChange::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, @@ -548,6 +566,8 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Events::TestEvent::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Events::TestFabricScopedEvent::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::SampleMei::Events::PingCountEvent::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType & value); 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 b481d620a2a43b..1a33c71a4eb1b2 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -102,6 +102,7 @@ | ActivatedCarbonFilterMonitoring | 0x0072 | | BooleanSensorConfiguration | 0x0080 | | ValveConfigurationAndControl | 0x0081 | +| ElectricalEnergyMeasurement | 0x0091 | | DemandResponseLoadControl | 0x0096 | | DeviceEnergyManagement | 0x0098 | | EnergyEvse | 0x0099 | @@ -76007,6 +76008,966 @@ class SubscribeAttributeValveConfigurationAndControlClusterRevision : public Sub } }; +#endif // MTR_ENABLE_PROVISIONAL +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalEnergyMeasurement | 0x0091 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * Accuracy | 0x0000 | +| * CumulativeEnergyImported | 0x0001 | +| * CumulativeEnergyExported | 0x0002 | +| * PeriodicEnergyImported | 0x0003 | +| * PeriodicEnergyExported | 0x0004 | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +| * CumulativeEnergyMeasured | 0x0000 | +| * PeriodicEnergyMeasured | 0x0001 | +\*----------------------------------------------------------------------------*/ + +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute Accuracy + */ +class ReadElectricalEnergyMeasurementAccuracy : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementAccuracy() + : ReadAttribute("accuracy") + { + } + + ~ReadElectricalEnergyMeasurementAccuracy() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::Accuracy::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAccuracyWithCompletion:^(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.Accuracy response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement Accuracy read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementAccuracy : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementAccuracy() + : SubscribeAttribute("accuracy") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementAccuracy() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::Accuracy::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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 subscribeAttributeAccuracyWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRElectricalEnergyMeasurementClusterMeasurementAccuracyStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.Accuracy response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute CumulativeEnergyImported + */ +class ReadElectricalEnergyMeasurementCumulativeEnergyImported : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementCumulativeEnergyImported() + : ReadAttribute("cumulative-energy-imported") + { + } + + ~ReadElectricalEnergyMeasurementCumulativeEnergyImported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::CumulativeEnergyImported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeCumulativeEnergyImportedWithCompletion:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.CumulativeEnergyImported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement CumulativeEnergyImported read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyImported : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyImported() + : SubscribeAttribute("cumulative-energy-imported") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyImported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::CumulativeEnergyImported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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 subscribeAttributeCumulativeEnergyImportedWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.CumulativeEnergyImported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute CumulativeEnergyExported + */ +class ReadElectricalEnergyMeasurementCumulativeEnergyExported : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementCumulativeEnergyExported() + : ReadAttribute("cumulative-energy-exported") + { + } + + ~ReadElectricalEnergyMeasurementCumulativeEnergyExported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::CumulativeEnergyExported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeCumulativeEnergyExportedWithCompletion:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.CumulativeEnergyExported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement CumulativeEnergyExported read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyExported : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyExported() + : SubscribeAttribute("cumulative-energy-exported") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementCumulativeEnergyExported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::CumulativeEnergyExported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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 subscribeAttributeCumulativeEnergyExportedWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.CumulativeEnergyExported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute PeriodicEnergyImported + */ +class ReadElectricalEnergyMeasurementPeriodicEnergyImported : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementPeriodicEnergyImported() + : ReadAttribute("periodic-energy-imported") + { + } + + ~ReadElectricalEnergyMeasurementPeriodicEnergyImported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::PeriodicEnergyImported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributePeriodicEnergyImportedWithCompletion:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.PeriodicEnergyImported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement PeriodicEnergyImported read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyImported : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyImported() + : SubscribeAttribute("periodic-energy-imported") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyImported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::PeriodicEnergyImported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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 subscribeAttributePeriodicEnergyImportedWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.PeriodicEnergyImported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute PeriodicEnergyExported + */ +class ReadElectricalEnergyMeasurementPeriodicEnergyExported : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementPeriodicEnergyExported() + : ReadAttribute("periodic-energy-exported") + { + } + + ~ReadElectricalEnergyMeasurementPeriodicEnergyExported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::PeriodicEnergyExported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributePeriodicEnergyExportedWithCompletion:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.PeriodicEnergyExported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement PeriodicEnergyExported read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyExported : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyExported() + : SubscribeAttribute("periodic-energy-exported") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementPeriodicEnergyExported() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::PeriodicEnergyExported::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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 subscribeAttributePeriodicEnergyExportedWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRElectricalEnergyMeasurementClusterEnergyMeasurementStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.PeriodicEnergyExported response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute GeneratedCommandList + */ +class ReadElectricalEnergyMeasurementGeneratedCommandList : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementGeneratedCommandList() + : ReadAttribute("generated-command-list") + { + } + + ~ReadElectricalEnergyMeasurementGeneratedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.GeneratedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement GeneratedCommandList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementGeneratedCommandList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementGeneratedCommandList() + : SubscribeAttribute("generated-command-list") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementGeneratedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::GeneratedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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(@"ElectricalEnergyMeasurement.GeneratedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AcceptedCommandList + */ +class ReadElectricalEnergyMeasurementAcceptedCommandList : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementAcceptedCommandList() + : ReadAttribute("accepted-command-list") + { + } + + ~ReadElectricalEnergyMeasurementAcceptedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::AcceptedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.AcceptedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement AcceptedCommandList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementAcceptedCommandList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementAcceptedCommandList() + : SubscribeAttribute("accepted-command-list") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementAcceptedCommandList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::AcceptedCommandList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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(@"ElectricalEnergyMeasurement.AcceptedCommandList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute EventList + */ +class ReadElectricalEnergyMeasurementEventList : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementEventList() + : ReadAttribute("event-list") + { + } + + ~ReadElectricalEnergyMeasurementEventList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::EventList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeEventListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.EventList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement EventList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementEventList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementEventList() + : SubscribeAttribute("event-list") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementEventList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::EventList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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 subscribeAttributeEventListWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.EventList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute AttributeList + */ +class ReadElectricalEnergyMeasurementAttributeList : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementAttributeList() + : ReadAttribute("attribute-list") + { + } + + ~ReadElectricalEnergyMeasurementAttributeList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::AttributeList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.AttributeList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement AttributeList read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementAttributeList : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementAttributeList() + : SubscribeAttribute("attribute-list") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementAttributeList() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::AttributeList::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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(@"ElectricalEnergyMeasurement.AttributeList response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute FeatureMap + */ +class ReadElectricalEnergyMeasurementFeatureMap : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementFeatureMap() + : ReadAttribute("feature-map") + { + } + + ~ReadElectricalEnergyMeasurementFeatureMap() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::FeatureMap::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.FeatureMap response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement FeatureMap read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementFeatureMap : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementFeatureMap() + : SubscribeAttribute("feature-map") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementFeatureMap() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::FeatureMap::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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(@"ElectricalEnergyMeasurement.FeatureMap response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute ClusterRevision + */ +class ReadElectricalEnergyMeasurementClusterRevision : public ReadAttribute { +public: + ReadElectricalEnergyMeasurementClusterRevision() + : ReadAttribute("cluster-revision") + { + } + + ~ReadElectricalEnergyMeasurementClusterRevision() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::ClusterRevision::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"ElectricalEnergyMeasurement.ClusterRevision response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("ElectricalEnergyMeasurement ClusterRevision read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeElectricalEnergyMeasurementClusterRevision : public SubscribeAttribute { +public: + SubscribeAttributeElectricalEnergyMeasurementClusterRevision() + : SubscribeAttribute("cluster-revision") + { + } + + ~SubscribeAttributeElectricalEnergyMeasurementClusterRevision() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::ElectricalEnergyMeasurement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::ElectricalEnergyMeasurement::Attributes::ClusterRevision::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterElectricalEnergyMeasurement 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(@"ElectricalEnergyMeasurement.ClusterRevision response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + #endif // MTR_ENABLE_PROVISIONAL #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL @@ -171277,6 +172238,7 @@ class SubscribeAttributeUnitTestingClusterRevision : public SubscribeAttribute { | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * PingCountEvent | 0x0000 | \*----------------------------------------------------------------------------*/ #if MTR_ENABLE_PROVISIONAL @@ -175473,6 +176435,69 @@ void registerClusterValveConfigurationAndControl(Commands & commands) commands.RegisterCluster(clusterName, clusterCommands); #endif // MTR_ENABLE_PROVISIONAL } +void registerClusterElectricalEnergyMeasurement(Commands & commands) +{ +#if MTR_ENABLE_PROVISIONAL + using namespace chip::app::Clusters::ElectricalEnergyMeasurement; + + const char * clusterName = "ElectricalEnergyMeasurement"; + + commands_list clusterCommands = { + make_unique(Id), // + make_unique(Id), // + make_unique(Id), // + make_unique(Id), // +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL + make_unique(Id), // + make_unique(Id), // + }; + + commands.RegisterCluster(clusterName, clusterCommands); +#endif // MTR_ENABLE_PROVISIONAL +} void registerClusterDemandResponseLoadControl(Commands & commands) { #if MTR_ENABLE_PROVISIONAL @@ -179057,6 +180082,8 @@ void registerClusterSampleMei(Commands & commands) make_unique(), // make_unique(), // #endif // MTR_ENABLE_PROVISIONAL + make_unique(Id), // + make_unique(Id), // }; commands.RegisterCluster(clusterName, clusterCommands); @@ -179145,6 +180172,7 @@ void registerClusters(Commands & commands) registerClusterActivatedCarbonFilterMonitoring(commands); registerClusterBooleanSensorConfiguration(commands); registerClusterValveConfigurationAndControl(commands); + registerClusterElectricalEnergyMeasurement(commands); registerClusterDemandResponseLoadControl(commands); registerClusterDeviceEnergyManagement(commands); registerClusterEnergyEvse(commands);