diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 8ba2c1b3986e15..d33643beb5ddce 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -202,6 +202,13 @@ menu "CHIP Core" help Enable this option to use LwIP default IPv6 route hook for Route Information Option(RIO) feature. + config ENABLE_ENDPOINT_QUEUE_FILTER + bool "Enable UDP Endpoint queue filter for mDNS Broadcast packets" + depends on USE_MINIMAL_MDNS + default y + help + Enable this option to start a UDP Endpoint queue filter for mDNS Broadcast packets + config ENABLE_LWIP_THREAD_SAFETY bool "Enable LwIP Thread safety options" default y @@ -1038,6 +1045,12 @@ menu "CHIP Device Layer" endmenu + config CHIP_ENABLE_BDX_LOG_TRANSFER + bool "Enable BDX log transfer" + default n + help + Enables the BDX protocol for diagnostics log transfer + menu "Matter OTA Image" config CHIP_OTA_IMAGE_BUILD diff --git a/examples/air-quality-sensor-app/linux/README.md b/examples/air-quality-sensor-app/linux/README.md index 6641a3e2f07de5..73139ef4aeeacb 100644 --- a/examples/air-quality-sensor-app/linux/README.md +++ b/examples/air-quality-sensor-app/linux/README.md @@ -152,3 +152,16 @@ Generate event `CarbonDioxideConcentrationMeasurement`, to change the CO2 value. ``` $ echo '{"Name":"CarbonDioxideConcentrationMeasurement","NewValue":400}' > /tmp/chip_air_quality_fifo_ ``` + +Generate event `CarbonMonoxideConcentrationMeasurement`, to change the CO value. + +``` +$ echo '{"Name":"CarbonMonoxideConcentrationMeasurement","NewValue":1}' > /tmp/chip_air_quality_fifo_ +``` + +Generate event `NitrogenDioxideConcentrationMeasurement`, to change the NO₂ +value. + +``` +$ echo '{"Name":"NitrogenDioxideConcentrationMeasurement","NewValue":1}' > /tmp/chip_air_quality_fifo_ +``` diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.matter b/examples/energy-management-app/energy-management-common/energy-management-app.matter index 0e997312433125..bb8d99f7e62ec7 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.matter +++ b/examples/energy-management-app/energy-management-common/energy-management-app.matter @@ -256,6 +256,67 @@ cluster BasicInformation = 40 { command MfgSpecificPing(): DefaultSuccess = 0; } +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc */ +cluster LocalizationConfiguration = 43 { + revision 1; // NOTE: Default/not specifically set + + attribute access(write: manage) char_string<35> activeLocale = 0; + readonly attribute char_string supportedLocales[] = 1; + 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; +} + +/** Nodes should be expected to be deployed to any and all regions of the world. These global regions + may have differing preferences for how dates and times are conveyed. As such, Nodes that visually + or audibly convey time information need a mechanism by which they can be configured to use a + user’s preferred format. */ +cluster TimeFormatLocalization = 44 { + revision 1; // NOTE: Default/not specifically set + + enum CalendarTypeEnum : enum8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + kUseActiveLocale = 255; + } + + enum HourFormatEnum : enum8 { + k12hr = 0; + k24hr = 1; + kUseActiveLocale = 255; + } + + bitmap Feature : bitmap32 { + kCalendarFormat = 0x1; + } + + attribute access(write: manage) HourFormatEnum hourFormat = 0; + attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; + 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; +} + /** Nodes should be expected to be deployed to any and all regions of the world. These global regions may have differing preferences for the units in which values are conveyed in communication to a user. As such, Nodes that visually or audibly convey measurable values to the user need a @@ -900,6 +961,111 @@ cluster GroupKeyManagement = 63 { fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4; } +/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */ +provisional cluster ElectricalPowerMeasurement = 144 { + 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; + } + + enum PowerModeEnum : enum8 { + kUnknown = 0; + kDC = 1; + kAC = 2; + } + + bitmap Feature : bitmap32 { + kDirectCurrent = 0x1; + kAlternatingCurrent = 0x2; + kPolyphasePower = 0x4; + kHarmonics = 0x8; + kPowerQuality = 0x10; + } + + 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 HarmonicMeasurementStruct { + int8u order = 0; + nullable int64s measurement = 1; + } + + struct MeasurementRangeStruct { + MeasurementTypeEnum measurementType = 0; + int64s min = 1; + int64s max = 2; + optional epoch_s startTimestamp = 3; + optional epoch_s endTimestamp = 4; + optional epoch_s minTimestamp = 5; + optional epoch_s maxTimestamp = 6; + optional systime_ms startSystime = 7; + optional systime_ms endSystime = 8; + optional systime_ms minSystime = 9; + optional systime_ms maxSystime = 10; + } + + info event MeasurementPeriodRanges = 0 { + MeasurementRangeStruct ranges[] = 0; + } + + readonly attribute PowerModeEnum powerMode = 0; + readonly attribute int8u numberOfMeasurementTypes = 1; + readonly attribute MeasurementAccuracyStruct accuracy[] = 2; + readonly attribute optional MeasurementRangeStruct ranges[] = 3; + readonly attribute optional nullable voltage_mv voltage = 4; + readonly attribute optional nullable amperage_ma activeCurrent = 5; + readonly attribute optional nullable amperage_ma reactiveCurrent = 6; + readonly attribute optional nullable amperage_ma apparentCurrent = 7; + readonly attribute nullable power_mw activePower = 8; + readonly attribute optional nullable power_mw reactivePower = 9; + readonly attribute optional nullable power_mw apparentPower = 10; + readonly attribute optional nullable voltage_mv RMSVoltage = 11; + readonly attribute optional nullable amperage_ma RMSCurrent = 12; + readonly attribute optional nullable power_mw RMSPower = 13; + readonly attribute optional nullable int64s frequency = 14; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicCurrents[] = 15; + readonly attribute optional nullable HarmonicMeasurementStruct harmonicPhases[] = 16; + readonly attribute optional nullable int64s powerFactor = 17; + readonly attribute optional nullable amperage_ma neutralCurrent = 18; + 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 a mechanism for querying data about the electrical energy imported or provided by the server. */ provisional cluster ElectricalEnergyMeasurement = 145 { revision 1; @@ -1530,6 +1696,27 @@ endpoint 0 { ram attribute clusterRevision default = 3; } + server cluster LocalizationConfiguration { + ram attribute activeLocale; + callback attribute supportedLocales; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + + server cluster TimeFormatLocalization { + ram attribute hourFormat; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + server cluster UnitLocalization { callback attribute generatedCommandList; callback attribute acceptedCommandList; @@ -1578,6 +1765,7 @@ endpoint 0 { server cluster GeneralDiagnostics { callback attribute networkInterfaces; callback attribute rebootCount; + callback attribute upTime; ram attribute testEventTriggersEnabled; callback attribute generatedCommandList; callback attribute acceptedCommandList; @@ -1655,7 +1843,7 @@ endpoint 0 { } } endpoint 1 { - device type ma_lightsensor = 262, version 1; + device type energy_evse = 1292, version 1; server cluster Identify { @@ -1685,6 +1873,19 @@ endpoint 1 { callback attribute clusterRevision; } + server cluster ElectricalPowerMeasurement { + callback attribute powerMode; + callback attribute numberOfMeasurementTypes; + callback attribute accuracy; + callback attribute activePower; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + callback attribute featureMap; + ram attribute clusterRevision default = 1; + } + server cluster ElectricalEnergyMeasurement { emits event CumulativeEnergyMeasured; callback attribute accuracy; diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.zap b/examples/energy-management-app/energy-management-common/energy-management-app.zap index 0e1f15b808317d..ed18c81d0738e5 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.zap +++ b/examples/energy-management-app/energy-management-common/energy-management-app.zap @@ -746,6 +746,266 @@ } ] }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "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": "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": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormatEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": 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": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Unit Localization", "code": 45, @@ -1356,6 +1616,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "TestEventTriggersEnabled", "code": 8, @@ -2168,27 +2444,27 @@ "id": 2, "name": "Anonymous Endpoint Type", "deviceTypeRef": { - "code": 262, + "code": 1292, "profileId": 259, - "label": "MA-lightsensor", - "name": "MA-lightsensor" + "label": "Energy EVSE", + "name": "Energy EVSE" }, "deviceTypes": [ { - "code": 262, + "code": 1292, "profileId": 259, - "label": "MA-lightsensor", - "name": "MA-lightsensor" + "label": "Energy EVSE", + "name": "Energy EVSE" } ], "deviceVersions": [ 1 ], "deviceIdentifiers": [ - 262 + 1292 ], - "deviceTypeName": "MA-lightsensor", - "deviceTypeCode": 262, + "deviceTypeName": "Energy EVSE", + "deviceTypeCode": 1292, "deviceTypeProfileId": 259, "clusters": [ { @@ -2517,6 +2793,177 @@ } ] }, + { + "name": "Electrical Power Measurement", + "code": 144, + "mfgCode": null, + "define": "ELECTRICAL_POWER_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "provisional", + "attributes": [ + { + "name": "PowerMode", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PowerModeEnum", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NumberOfMeasurementTypes", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Accuracy", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActivePower", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "power_mw", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Electrical Energy Measurement", "code": 145, @@ -2629,10 +3076,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 2a5819e69cf915..89af61e0919161 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -2789,7 +2789,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } 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 58f5c72eb4578a..3d15cf009086d8 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 @@ -3879,14 +3879,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/light-switch-app/silabs/openthread.gni b/examples/light-switch-app/silabs/openthread.gni index 19b09c05a8f4b6..2ea7cd471c2b8a 100644 --- a/examples/light-switch-app/silabs/openthread.gni +++ b/examples/light-switch-app/silabs/openthread.gni @@ -31,7 +31,7 @@ chip_subscription_timeout_resumption = false sl_use_subscription_synching = true # Openthread Configuration flags -sl_ot_idle_interval_ms = 30000 # 30s Idle Intervals +sl_ot_idle_interval_ms = 15000 # 15s Idle Intervals sl_ot_active_interval_ms = 500 # 500ms Active Intervals # ICD Matter Configuration flags diff --git a/examples/light-switch-app/silabs/src/AppTask.cpp b/examples/light-switch-app/silabs/src/AppTask.cpp index 2f8d01275863be..c9759d24118fdd 100644 --- a/examples/light-switch-app/silabs/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/src/AppTask.cpp @@ -25,29 +25,24 @@ #include "AppConfig.h" #include "AppEvent.h" #include "BindingHandler.h" - #include "LEDWidget.h" - #include "LightSwitchMgr.h" - #ifdef DISPLAY_ENABLED #include "lcd.h" #ifdef QR_CODE_ENABLED #include "qrcodegen.h" #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED - #include #include #include #include #include #include +#include #include #include -#include - /********************************************************** * Defines and Constants *********************************************************/ diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter index 86db7ac353c727..81407921094ffc 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter @@ -2615,7 +2615,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } 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 55b06213c5794b..eb3e958009ace5 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap @@ -2968,14 +2968,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter index b52944de7a3f8c..206679aa0bb228 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter @@ -2475,7 +2475,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } 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 3cf074afc1b0b6..c99d5e4716fcc9 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap @@ -2152,14 +2152,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 3a78cf774c8c5a..e9fed8d924c3e0 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -113,7 +113,11 @@ CHIP_ERROR SilabsMatterConfig::InitOpenThread(void) ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router)); #else // CHIP_DEVICE_CONFIG_THREAD_FTD #if CHIP_CONFIG_ENABLE_ICD_SERVER +#if CHIP_DEVICE_CONFIG_THREAD_SSED + ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice)); +#else ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice)); +#endif #else // CHIP_CONFIG_ENABLE_ICD_SERVER ReturnErrorOnFailure(ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice)); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER diff --git a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h index e906e48ab02684..d7492f4044f3fa 100644 --- a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h +++ b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h @@ -45,35 +45,39 @@ // Timeout after 2 missed checkin or 4 mins if sleep interval is too short. #define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1)) +#if defined(SL_CSL_ENABLE) && SL_CSL_ENABLE + +#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1 +#define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 1 +#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1 +#define OPENTHREAD_CONFIG_CHILD_SUPERVISION_CHECK_TIMEOUT 0 +#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 750 +#define OPENTHREAD_CONFIG_CSL_TIMEOUT SL_CSL_TIMEOUT +#define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 200 + +#endif // SL_CSL_ENABLE + #endif // SL_ICD_ENABLED /****Uncomment below section for OpenThread Debug logs*/ // #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG // #ifndef OPENTHREAD_CONFIG_LOG_CLI -// #define OPENTHREAD_CONFIG_LOG_CLI 1 +// #define OPENTHREAD_CONFIG_LOG_CLI 1 // #endif // #ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP -// #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 +// #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 // #endif // #ifndef OPENTHREAD_CONFIG_LOG_PLATFORM -// #define OPENTHREAD_CONFIG_LOG_PLATFORM 1 +// #define OPENTHREAD_CONFIG_LOG_PLATFORM 1 // #endif // #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL -// #define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 +// #define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 // #endif -// EFR32MG21A020F1024IM32 has 96k of RAM. Reduce the number of buffers to -// conserve RAM for this Series 2 part. -#if defined(EFR32MG21) -#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 22 -#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 512 -#define OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE 512 -#endif - #define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1 #define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 diff --git a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter index 7ca0706457f11b..4fee2b90c697f9 100644 --- a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter +++ b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter @@ -2140,7 +2140,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } 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 4cfe5ceb8ceca5..11413ba936714d 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 @@ -2902,14 +2902,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/temperature-measurement-app/esp32/README.md b/examples/temperature-measurement-app/esp32/README.md index 567e302c6f8df8..18d07ff639b06a 100644 --- a/examples/temperature-measurement-app/esp32/README.md +++ b/examples/temperature-measurement-app/esp32/README.md @@ -24,6 +24,36 @@ Usage: ./out/debug/chip-tool temperaturemeasurement read measured-value 1 ``` +## Additional details + +This example demonstrates the utilization of the diagnostic logs cluster to send +diagnostic logs to the client. + +In this scenario, the [main/diagnostic_logs](main/diagnostic_logs) directory +contains three files: + +``` +main/diagnostic_logs +├── crash.log +├── end_user_support.log +└── network_diag.log +``` + +These files contain dummy data. + +#### To test the diagnostic logs cluster + +``` +# Commission the app +chip-tool pairing ble-wifi 1 SSID PASSPHRASE 20202021 3840 + +# Read end user support logs using response payload protocol +chip-tool diagnosticlogs retrieve-logs-request 0 0 1 0 + +# Read network diagnostic using BDX protocol +chip-tool diagnosticlogs retrieve-logs-request 1 0 1 0 --TransferFileDesignator network-diag.log +``` + ## Optimization Optimization related to WiFi, BLuetooth, Asserts etc are the part of this diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index b48d05d8949b88..8953d34869b76a 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -82,7 +82,8 @@ endif (CONFIG_ENABLE_PW_RPC) idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} SRC_DIRS ${SRC_DIRS_LIST} - PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) + PRIV_REQUIRES ${PRIV_REQUIRES_LIST} + EMBED_FILES diagnostic_logs/end_user_support.log diagnostic_logs/network_diag.log diagnostic_logs/crash.log) include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") chip_app_component_codegen("${CHIP_ROOT}/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter") diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp new file mode 100644 index 00000000000000..4bef0fbd86cc19 --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -0,0 +1,161 @@ +/* + * + * Copyright (c) 2024 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 + +using namespace chip; +using namespace chip::app::Clusters::DiagnosticLogs; + +LogProvider LogProvider::sInstance; + +namespace { +bool IsValidIntent(IntentEnum intent) +{ + return intent != IntentEnum::kUnknownEnumValue; +} + +// end_user_support.log, network_diag.log, and crash.log files are embedded in the firmware +extern const uint8_t endUserSupportLogStart[] asm("_binary_end_user_support_log_start"); +extern const uint8_t endUserSupportLogEnd[] asm("_binary_end_user_support_log_end"); + +extern const uint8_t networkDiagnosticLogStart[] asm("_binary_network_diag_log_start"); +extern const uint8_t networkDiagnosticLogEnd[] asm("_binary_network_diag_log_end"); + +extern const uint8_t crashLogStart[] asm("_binary_crash_log_start"); +extern const uint8_t crashLogEnd[] asm("_binary_crash_log_end"); +} // namespace + +LogProvider::~LogProvider() +{ + for (auto sessionSpan : mSessionSpanMap) + { + Platform::MemoryFree(sessionSpan.second); + } + mSessionSpanMap.clear(); +} + +CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, + Optional & outTimeSinceBoot) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + LogSessionHandle sessionHandle = kInvalidLogSessionHandle; + + err = StartLogCollection(intent, sessionHandle, outTimeStamp, outTimeSinceBoot); + VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + + bool unusedOutIsEndOfLog; + err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); + VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + + err = EndLogCollection(sessionHandle); + VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + + return CHIP_NO_ERROR; +} + +const uint8_t * LogProvider::GetDataStartForIntent(IntentEnum intent) +{ + switch (intent) + { + case IntentEnum::kEndUserSupport: + return &endUserSupportLogStart[0]; + case IntentEnum::kNetworkDiag: + return &networkDiagnosticLogStart[0]; + case IntentEnum::kCrashLogs: + return &crashLogStart[0]; + default: + return nullptr; + } +} + +size_t LogProvider::GetSizeForIntent(IntentEnum intent) +{ + switch (intent) + { + case IntentEnum::kEndUserSupport: + return static_cast(endUserSupportLogEnd - endUserSupportLogStart); + case IntentEnum::kNetworkDiag: + return static_cast(networkDiagnosticLogEnd - networkDiagnosticLogStart); + case IntentEnum::kCrashLogs: + return static_cast(crashLogEnd - crashLogStart); + default: + return 0; + } +} + +CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, + Optional & outTimeSinceBoot) +{ + VerifyOrReturnValue(IsValidIntent(intent), CHIP_ERROR_INVALID_ARGUMENT); + + const uint8_t * dataStart = GetDataStartForIntent(intent); + VerifyOrReturnError(dataStart, CHIP_ERROR_NOT_FOUND); + + size_t dataSize = GetSizeForIntent(intent); + VerifyOrReturnError(dataSize, CHIP_ERROR_NOT_FOUND); + + ByteSpan * span = reinterpret_cast(Platform::MemoryCalloc(1, sizeof(ByteSpan))); + VerifyOrReturnValue(span, CHIP_ERROR_NO_MEMORY); + + *span = ByteSpan(dataStart, dataSize); + + mLogSessionHandle++; + // If the session handle rolls over to UINT16_MAX which is invalid, reset to 0. + VerifyOrDo(mLogSessionHandle != kInvalidLogSessionHandle, mLogSessionHandle = 0); + + outHandle = mLogSessionHandle; + mSessionSpanMap[mLogSessionHandle] = span; + return CHIP_NO_ERROR; +} + +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) +{ + VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnValue(mSessionSpanMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); + + ByteSpan * span = mSessionSpanMap[sessionHandle]; + mSessionSpanMap.erase(sessionHandle); + + Platform::MemoryFree(span); + return CHIP_NO_ERROR; +} + +CHIP_ERROR LogProvider::CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) +{ + VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnValue(mSessionSpanMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); + + ByteSpan * span = mSessionSpanMap[sessionHandle]; + auto dataSize = span->size(); + auto count = std::min(dataSize, outBuffer.size()); + + VerifyOrReturnError(CanCastTo(count), CHIP_ERROR_INVALID_ARGUMENT, outBuffer.reduce_size(0)); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(span->data(), count), outBuffer)); + + outIsEndOfLog = dataSize == count; + + if (!outIsEndOfLog) + { + // reduce the span after reading count bytes + *span = span->SubSpan(count); + } + + return CHIP_NO_ERROR; +} diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic_logs/crash.log b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/crash.log new file mode 100644 index 00000000000000..04089de8ce7afd --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/crash.log @@ -0,0 +1,21 @@ +W (5047Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. + +Core 0 register dump: +PC : 0x4009579a PS : 0x00060c33 A0 : 0x800941e1 A1 : 0x3fff3630 +0x4009579a: uxListRemove at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/list.c:195 + +A2 : 0x00000006 A3 : 0x00060c20 A4 : 0x00000000 A5 : 0x00060c23 +A6 : 0xb33fffff A7 : 0xb33fffff A8 : 0x800950f0 A9 : 0x3fff3600 +A10 : 0x00000001 A11 : 0x000000fe A12 : 0x00000000 A13 : 0x00000000 +A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c +EXCVADDR: 0x00000016 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff +0x4000c2e0: memcpy in ROM +0x4000c2f6: memcpy in ROM + +Backtrace: 0x40095797:0x3fff3630 0x400941de:0x3fff3650 0x40154b39:0x3fff3670 0x40154b53:0x3fff3690 0x4013e20d:0x3fff36b0 0x40094fa6:0x3fff36d0 +0x40095797: uxListRemove at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/list.c:202 +0x400941de: vTaskDelete at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:1434 (discriminator 4) +0x40154b39: esp_nimble_disable at /opt/espressif/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c:55 +0x40154b53: nimble_port_freertos_deinit at /opt/espressif/esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c:80 +0x4013e20d: chip::DeviceLayer::Internal::BLEManagerImpl::bleprph_host_task(void*) at /home/smart/projects/smp_matter/build/esp-idf/chip/../../../../../../../opt/espressif/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/platform/ESP32/nimble/BLEManagerImpl.cpp:864 +0x40094fa6: vPortTaskWrapper at /opt/espressif/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162 diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic_logs/end_user_support.log b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/end_user_support.log new file mode 100644 index 00000000000000..2844b97dab5988 --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/end_user_support.log @@ -0,0 +1,3 @@ +I (223374) chip[light]: Turning on the smart light. +I (233374) chip[light]: Setting smart light level to 78 %. +I (243374) chip[light]: Turning off the smart light. diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic_logs/network_diag.log b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/network_diag.log new file mode 100644 index 00000000000000..2b945b9cf4f48d --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/diagnostic_logs/network_diag.log @@ -0,0 +1,4 @@ +I (223374) chip[ndiag]: Wi-Fi connection status: 1 +I (233374) chip[ndiag]: Wi-Fi RSSI: -67 dBm +I (243374) chip[ndiag]: Minimum ever Wi-Fi RSSI: -80 dBm +I (253374) chip[ndiag]: Wi-Fi disconnection count: 16 diff --git a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h new file mode 100644 index 00000000000000..d47dccafa6079d --- /dev/null +++ b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2024 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 DiagnosticLogs { + +/** + * The LogProvider class serves as the sole instance delegate for handling diagnostic logs. + * + * It implements the DiagnosticLogsProviderDelegate interface + */ + +class LogProvider : public DiagnosticLogsProviderDelegate +{ +public: + static inline LogProvider & GetInstance() { return sInstance; } + + /////////// DiagnosticLogsProviderDelegate Interface ///////// + CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, + Optional & outTimeSinceBoot) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; + CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; + size_t GetSizeForIntent(IntentEnum intent) override; + CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, + Optional & outTimeSinceBoot) override; + +private: + static LogProvider sInstance; + LogProvider() = default; + ~LogProvider(); + + LogProvider(const LogProvider &) = delete; + LogProvider & operator=(const LogProvider &) = delete; + + // This tracks the ByteSpan for each session + std::map mSessionSpanMap; + + LogSessionHandle mLogSessionHandle = kInvalidLogSessionHandle; + + const uint8_t * GetDataStartForIntent(IntentEnum intent); +}; + +} // namespace DiagnosticLogs +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/temperature-measurement-app/esp32/main/main.cpp b/examples/temperature-measurement-app/esp32/main/main.cpp index cb9ba768412772..9f7a73011a19a8 100644 --- a/examples/temperature-measurement-app/esp32/main/main.cpp +++ b/examples/temperature-measurement-app/esp32/main/main.cpp @@ -24,11 +24,13 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "nvs_flash.h" +#include #include #include #include #include #include +#include #include #include @@ -127,3 +129,10 @@ extern "C" void app_main() chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); } + +using namespace chip::app::Clusters::DiagnosticLogs; +void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint) +{ + auto & logProvider = LogProvider::GetInstance(); + DiagnosticLogsServer::Instance().SetDiagnosticLogsProviderDelegate(endpoint, &logProvider); +} diff --git a/examples/temperature-measurement-app/esp32/sdkconfig.defaults b/examples/temperature-measurement-app/esp32/sdkconfig.defaults index 81070fbfddb449..6d3243cabfeb8c 100644 --- a/examples/temperature-measurement-app/esp32/sdkconfig.defaults +++ b/examples/temperature-measurement-app/esp32/sdkconfig.defaults @@ -96,3 +96,6 @@ CONFIG_MBEDTLS_HKDF_C=y # Increase LwIP IPv6 address number CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 + +# Enable the diagnostic logs transfer over BDX protocol +CONFIG_CHIP_ENABLE_BDX_LOG_TRANSFER=y diff --git a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter index 4ee09b5869aaa4..fbd355a0b36da2 100644 --- a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter +++ b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter @@ -1452,10 +1452,15 @@ endpoint 0 { } server cluster DiagnosticLogs { + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; handle command RetrieveLogsRequest; + handle command RetrieveLogsResponse; } server cluster GeneralDiagnostics { 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 01453667d4538c..fde996ded8a2fb 100644 --- a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap +++ b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.zap @@ -1573,9 +1573,81 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "RetrieveLogsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 } ], "attributes": [ + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -3225,5 +3297,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 309c686e0756cb..537a6c66f20666 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -2369,7 +2369,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index 4909f50165ab55..651b0fd201a2f1 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -3616,14 +3616,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index b893f790792eb5..e2db6276265c91 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -2007,6 +2007,99 @@ cluster UserLabel = 65 { readonly attribute int16u clusterRevision = 65533; } +/** This cluster provides an interface for passing messages to be presented by a device. */ +cluster Messages = 151 { + revision 3; + + enum FutureMessagePreferenceEnum : enum8 { + kAllowed = 0; + kIncreased = 1; + kReduced = 2; + kDisallowed = 3; + kBanned = 4; + } + + enum MessagePriorityEnum : enum8 { + kLow = 0; + kMedium = 1; + kHigh = 2; + kCritical = 3; + } + + bitmap Feature : bitmap32 { + kReceivedConfirmation = 0x1; + kConfirmationResponse = 0x2; + kConfirmationReply = 0x4; + kProtectedMessages = 0x8; + } + + bitmap MessageControlBitmap : bitmap8 { + kConfirmationRequired = 0x1; + kResponseRequired = 0x2; + kReplyMessage = 0x4; + kMessageConfirmed = 0x8; + kMessageProtected = 0x10; + } + + struct MessageResponseOptionStruct { + optional int32u messageResponseID = 0; + optional char_string<32> label = 1; + } + + struct MessageStruct { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + info event MessageQueued = 0 { + octet_string messageID = 0; + } + + info event MessagePresented = 1 { + octet_string messageID = 0; + } + + info event MessageComplete = 2 { + octet_string messageID = 0; + optional nullable int32u responseID = 1; + optional nullable char_string reply = 2; + nullable FutureMessagePreferenceEnum futureMessagesPreference = 3; + } + + readonly attribute MessageStruct messages[] = 0; + readonly attribute octet_string activeMessageIDs[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct PresentMessagesRequestRequest { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + request struct CancelMessagesRequestRequest { + octet_string messageIDs[] = 0; + } + + /** Command for requesting messages be presented */ + fabric command PresentMessagesRequest(PresentMessagesRequestRequest): DefaultSuccess = 0; + /** Command for cancelling message present requests */ + fabric command CancelMessagesRequest(CancelMessagesRequestRequest): DefaultSuccess = 1; +} + /** Attributes and commands for configuring the measurement of relative humidity, and reporting relative humidity measurements. */ cluster RelativeHumidityMeasurement = 1029 { revision 3; @@ -3433,6 +3526,23 @@ endpoint 1 { callback attribute clusterRevision; } + server cluster Messages { + emits event MessageQueued; + emits event MessagePresented; + emits event MessageComplete; + callback attribute messages; + callback attribute activeMessageIDs; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 3; + + handle command PresentMessagesRequest; + handle command CancelMessagesRequest; + } + server cluster WakeOnLan { ram attribute MACAddress; ram attribute featureMap default = 0; diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index 955307dbf00c31..242fbba690931a 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -4691,6 +4691,185 @@ } ] }, + { + "name": "Messages", + "code": 151, + "mfgCode": null, + "define": "MESSAGES_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "PresentMessagesRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "CancelMessagesRequest", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "Messages", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveMessageIDs", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "MessageQueued", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MessagePresented", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MessageComplete", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Wake on LAN", "code": 1283, diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 16c934e5095488..50cf171b046f8c 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -1485,6 +1485,99 @@ cluster FixedLabel = 64 { readonly attribute int16u clusterRevision = 65533; } +/** This cluster provides an interface for passing messages to be presented by a device. */ +cluster Messages = 151 { + revision 3; + + enum FutureMessagePreferenceEnum : enum8 { + kAllowed = 0; + kIncreased = 1; + kReduced = 2; + kDisallowed = 3; + kBanned = 4; + } + + enum MessagePriorityEnum : enum8 { + kLow = 0; + kMedium = 1; + kHigh = 2; + kCritical = 3; + } + + bitmap Feature : bitmap32 { + kReceivedConfirmation = 0x1; + kConfirmationResponse = 0x2; + kConfirmationReply = 0x4; + kProtectedMessages = 0x8; + } + + bitmap MessageControlBitmap : bitmap8 { + kConfirmationRequired = 0x1; + kResponseRequired = 0x2; + kReplyMessage = 0x4; + kMessageConfirmed = 0x8; + kMessageProtected = 0x10; + } + + struct MessageResponseOptionStruct { + optional int32u messageResponseID = 0; + optional char_string<32> label = 1; + } + + struct MessageStruct { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + info event MessageQueued = 0 { + octet_string messageID = 0; + } + + info event MessagePresented = 1 { + octet_string messageID = 0; + } + + info event MessageComplete = 2 { + octet_string messageID = 0; + optional nullable int32u responseID = 1; + optional nullable char_string reply = 2; + nullable FutureMessagePreferenceEnum futureMessagesPreference = 3; + } + + readonly attribute MessageStruct messages[] = 0; + readonly attribute octet_string activeMessageIDs[] = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct PresentMessagesRequestRequest { + octet_string<16> messageID = 0; + MessagePriorityEnum priority = 1; + MessageControlBitmap messageControl = 2; + nullable epoch_s startTime = 3; + nullable int16u duration = 4; + char_string<256> messageText = 5; + optional MessageResponseOptionStruct responses[] = 6; + } + + request struct CancelMessagesRequestRequest { + octet_string messageIDs[] = 0; + } + + /** Command for requesting messages be presented */ + fabric command PresentMessagesRequest(PresentMessagesRequestRequest): DefaultSuccess = 0; + /** Command for cancelling message present requests */ + fabric command CancelMessagesRequest(CancelMessagesRequestRequest): DefaultSuccess = 1; +} + /** This cluster provides an interface for managing low power mode on a device that supports the Wake On LAN protocol. */ cluster WakeOnLan = 1283 { revision 1; @@ -2763,6 +2856,7 @@ endpoint 1 { binding cluster OnOff; binding cluster LevelControl; binding cluster Descriptor; + binding cluster Messages; binding cluster WakeOnLan; binding cluster Channel; binding cluster TargetNavigator; 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 2bb394da30433d..955ef18532ce02 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 @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -3585,6 +3585,66 @@ } ] }, + { + "name": "Messages", + "code": 151, + "mfgCode": null, + "define": "MESSAGES_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "PresentMessagesRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "CancelMessagesRequest", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Wake on LAN", "code": 1283, diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index c8308305b71a9e..6247de65be5dcc 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -1810,6 +1810,91 @@ cluster UserLabel = 65 { readonly attribute int16u clusterRevision = 65533; } +/** Allows servers to ensure that listed clients are notified when a server is available for communication. */ +cluster IcdManagement = 70 { + revision 2; + + enum OperatingModeEnum : enum8 { + kSIT = 0; + kLIT = 1; + } + + bitmap Feature : bitmap32 { + kCheckInProtocolSupport = 0x1; + kUserActiveModeTrigger = 0x2; + kLongIdleTimeSupport = 0x4; + } + + bitmap UserActiveModeTriggerBitmap : bitmap32 { + kPowerCycle = 0x1; + kSettingsMenu = 0x2; + kCustomInstruction = 0x4; + kDeviceManual = 0x8; + kActuateSensor = 0x10; + kActuateSensorSeconds = 0x20; + kActuateSensorTimes = 0x40; + kActuateSensorLightsBlink = 0x80; + kResetButton = 0x100; + kResetButtonLightsBlink = 0x200; + kResetButtonSeconds = 0x400; + kResetButtonTimes = 0x800; + kSetupButton = 0x1000; + kSetupButtonSeconds = 0x2000; + kSetupButtonLightsBlink = 0x4000; + kSetupButtonTimes = 0x8000; + kAppDefinedButton = 0x10000; + } + + fabric_scoped struct MonitoringRegistrationStruct { + fabric_sensitive node_id checkInNodeID = 1; + fabric_sensitive int64u monitoredSubject = 2; + fabric_idx fabricIndex = 254; + } + + readonly attribute int32u idleModeDuration = 0; + readonly attribute int32u activeModeDuration = 1; + readonly attribute int16u activeModeThreshold = 2; + readonly attribute access(read: administer) optional MonitoringRegistrationStruct registeredClients[] = 3; + readonly attribute access(read: administer) optional int32u ICDCounter = 4; + readonly attribute optional int16u clientsSupportedPerFabric = 5; + readonly attribute optional UserActiveModeTriggerBitmap userActiveModeTriggerHint = 6; + readonly attribute optional char_string<128> userActiveModeTriggerInstruction = 7; + readonly attribute optional OperatingModeEnum operatingMode = 8; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct RegisterClientRequest { + node_id checkInNodeID = 0; + int64u monitoredSubject = 1; + octet_string<16> key = 2; + optional octet_string<16> verificationKey = 3; + } + + response struct RegisterClientResponse = 1 { + int32u ICDCounter = 0; + } + + request struct UnregisterClientRequest { + node_id checkInNodeID = 0; + optional octet_string<16> verificationKey = 1; + } + + response struct StayActiveResponse = 4 { + int32u promisedActiveDuration = 0; + } + + /** Register a client to the end device */ + fabric command access(invoke: manage) RegisterClient(RegisterClientRequest): RegisterClientResponse = 0; + /** Unregister a client from an end device */ + fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2; + /** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */ + command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3; +} + /** Provides an interface for controlling and adjusting automatic window coverings. */ cluster WindowCovering = 258 { revision 5; @@ -2297,7 +2382,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } @@ -2360,6 +2444,18 @@ endpoint 0 { ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } + + server cluster IcdManagement { + callback attribute idleModeDuration; + callback attribute activeModeDuration; + callback attribute activeModeThreshold; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0x0000; + ram attribute clusterRevision default = 2; + } } endpoint 1 { device type ma_windowcovering = 514, version 2; diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index 46ca5f520c42eb..1ce4a5db8e81f4 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -4266,14 +4266,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, @@ -5065,6 +5057,160 @@ "reportableChange": 0 } ] + }, + { + "name": "ICD Management", + "code": 70, + "mfgCode": null, + "define": "ICD_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "IdleModeDuration", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveModeDuration", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveModeThreshold", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "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": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] } ] }, diff --git a/examples/window-app/silabs/openthread.gn b/examples/window-app/silabs/openthread.gn index b05216fc9d7eae..27aa6c766a17e6 100644 --- a/examples/window-app/silabs/openthread.gn +++ b/examples/window-app/silabs/openthread.gn @@ -23,7 +23,7 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - chip_openthread_ftd = true + chip_openthread_ftd = false import("//openthread.gni") } diff --git a/examples/window-app/silabs/openthread.gni b/examples/window-app/silabs/openthread.gni index ffe5dc7c278205..cdd7f8c0f1f42e 100644 --- a/examples/window-app/silabs/openthread.gni +++ b/examples/window-app/silabs/openthread.gni @@ -24,3 +24,18 @@ chip_enable_openthread = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" + +# ICD Default configurations +chip_enable_icd_server = true +enable_synchronized_sed = true +chip_subscription_timeout_resumption = false +sl_use_subscription_synching = true + +# Openthread Configuration flags +sl_ot_idle_interval_ms = 1000 # 1s Idle Intervals +sl_ot_active_interval_ms = 500 # 500ms Active Intervals + +# ICD Matter Configuration flags +sl_idle_mode_interval_s = 600 # 10min Idle Mode Interval +sl_active_mode_interval_ms = 0 # 0s Active Mode Interval +sl_active_mode_threshold_ms = 0 # 1s Active Mode Threshold diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index 7c51e45e89e229..4a62ddb7795a85 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -34 : [Telink] Update Docker image (Zephyr update) +35 : [Telink] Update Docker image (Zephyr update) diff --git a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile index a057044c5a1fae..98de9d1c5c163f 100644 --- a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile @@ -12,7 +12,7 @@ RUN set -x \ && : # last line # Setup Zephyr -ARG ZEPHYR_REVISION=5bcb564c5bec3f3ebcaf7ae9949e053ef414df1f +ARG ZEPHYR_REVISION=c4dd151a1ffa96bfbd577ddc88a55c5785279514 WORKDIR /opt/telink/zephyrproject RUN set -x \ && python3 -m pip install -U --no-cache-dir west \ diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index fc8fcfd387f8fa..c69f9d495fa975 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -86,6 +86,10 @@ if [ "$#" == "0" ]; then chip_enable_icd_server Configure has a Intermitently connected device. (Default false) Must also set chip_openthread_ftd=false + enable_synchronized_sed + Enable Synchronized Sleepy end device. (Default false) + Must also set chip_enable_icd_server=true chip_openthread_ftd=false + --icd can be used to configure both arguments use_rs9116 Build wifi example with extension board rs9116. (Default false) use_SiWx917 diff --git a/scripts/tools/check_includes_config.py b/scripts/tools/check_includes_config.py index b4e933f193583c..42920c4014c133 100644 --- a/scripts/tools/check_includes_config.py +++ b/scripts/tools/check_includes_config.py @@ -158,7 +158,7 @@ # Library meant for non-embedded 'src/tracing/json/json_tracing.cpp': {'string', 'sstream'}, - 'src/tracing/json/json_tracing.h': {'fstream'}, + 'src/tracing/json/json_tracing.h': {'fstream', 'unordered_map'}, # Not intended for embedded clients 'src/lib/support/jsontlv/JsonToTlv.cpp': {'sstream'}, diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp index 217f44a3c61df2..8e919ef5bb7976 100644 --- a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -773,7 +773,7 @@ CHIP_ERROR TimeSynchronizationServer::SetUTCTime(EndpointId ep, uint64_t utcTime CHIP_ERROR err = UpdateUTCTime(utcTime); if (err != CHIP_NO_ERROR && !RuntimeOptionsProvider::Instance().GetSimulateNoInternalTime()) { - ChipLogError(Zcl, "Error setting UTC time on the device"); + ChipLogError(Zcl, "Error setting UTC time on the device: %" CHIP_ERROR_FORMAT, err.Format()); return err; } GetDelegate()->UTCTimeAvailabilityChanged(utcTime); diff --git a/src/app/icd/client/BUILD.gn b/src/app/icd/client/BUILD.gn index fa32e9c68dbfd4..1a1a5acdd34ae7 100644 --- a/src/app/icd/client/BUILD.gn +++ b/src/app/icd/client/BUILD.gn @@ -41,6 +41,8 @@ source_set("handler") { "CheckInHandler.h", "DefaultCheckInDelegate.cpp", "DefaultCheckInDelegate.h", + "RefreshKeySender.cpp", + "RefreshKeySender.h", ] public_deps = [ ":manager", diff --git a/src/app/icd/client/CheckInDelegate.h b/src/app/icd/client/CheckInDelegate.h index 50d378a87a58e7..5c931d414aab2c 100644 --- a/src/app/icd/client/CheckInDelegate.h +++ b/src/app/icd/client/CheckInDelegate.h @@ -19,10 +19,13 @@ #pragma once #include +#include namespace chip { namespace app { +class RefreshKeySender; + /// Callbacks for check in protocol /** * @brief The application implementing an ICD client should inherit the CheckInDelegate and implement the listed callbacks @@ -39,6 +42,40 @@ class DLL_EXPORT CheckInDelegate node that sent the check-in message. */ virtual void OnCheckInComplete(const ICDClientInfo & clientInfo) = 0; + + /** + * @brief Callback used to let the application know that a key refresh is + * needed to avoid counter rollover problems. + * + * The implementer of this function should create a new RefreshKeySender object. This object will be tied to the specific key + * refresh process and will not be used by the caller after that particular key refresh process has ended, regardless of success + * or failure. + * + * The caller guarantees that if a non-null RefreshKeySender pointer is returned, it will call OnKeyRefreshDone + * at some point, and pass it the returned pointer. + * + * If the callee is unable to provide the RefreshKeySender object, that indicates key + * refresh is not possible until the callee is able to provide the required resources. + * + * @param[in] clientInfo - ICDClientInfo object representing the state associated with the + * node that sent the check-in message. The callee can use the clientInfo to determine the type of key + * to generate. + * @param[in] clientStorage - ICDClientStorage object stores the updated ICDClientInfo after re-registration into + * persistent storage. + * @return RefreshKeySender - pointer to RefreshKeySender object + */ + virtual RefreshKeySender * OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) = 0; + + /** + * @brief Callback used to let the application know that the re-registration process is done. This callback will be called for + * both success and failure cases. On failure, the callee should take appropriate corrective action based on the error. + * + * @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller + * will NOT use this pointer any more. + * @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key + * Other errors indicate the failure reason. + */ + virtual void OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) = 0; }; } // namespace app diff --git a/src/app/icd/client/CheckInHandler.cpp b/src/app/icd/client/CheckInHandler.cpp index f05dcd8b7819ed..165301c45480fd 100644 --- a/src/app/icd/client/CheckInHandler.cpp +++ b/src/app/icd/client/CheckInHandler.cpp @@ -23,8 +23,8 @@ */ #include -#include #include +#include #include @@ -109,8 +109,20 @@ CHIP_ERROR CheckInHandler::OnMessageReceived(Messaging::ExchangeContext * ec, co if (refreshKey) { - // TODO: A new CASE session should be established to re-register the client using a new key. The registration will happen in - // CASE session callback + RefreshKeySender * refreshKeySender = mpCheckInDelegate->OnKeyRefreshNeeded(clientInfo, mpICDClientStorage); + if (refreshKeySender == nullptr) + { + ChipLogError(ICD, "Key Refresh failed for node ID:" ChipLogFormatScopedNodeId, + ChipLogValueScopedNodeId(clientInfo.peer_node)); + return CHIP_NO_ERROR; + } + err = refreshKeySender->EstablishSessionToPeer(); + if (CHIP_NO_ERROR != err) + { + ChipLogError(ICD, "CASE session establishment failed with error : %" CHIP_ERROR_FORMAT, err.Format()); + mpCheckInDelegate->OnKeyRefreshDone(refreshKeySender, err); + return CHIP_NO_ERROR; + } } else { diff --git a/src/app/icd/client/DefaultCheckInDelegate.cpp b/src/app/icd/client/DefaultCheckInDelegate.cpp index cec36d2db5660b..8df98006f6e9e0 100644 --- a/src/app/icd/client/DefaultCheckInDelegate.cpp +++ b/src/app/icd/client/DefaultCheckInDelegate.cpp @@ -15,13 +15,12 @@ * limitations under the License. */ -#include "CheckInHandler.h" #include #include +#include #include #include #include -#include namespace chip { namespace app { @@ -44,5 +43,42 @@ void DefaultCheckInDelegate::OnCheckInComplete(const ICDClientInfo & clientInfo) #endif } +RefreshKeySender * DefaultCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + RefreshKeySender::RefreshKeyBuffer newKey; + + err = Crypto::DRBG_get_bytes(newKey.Bytes(), newKey.Capacity()); + if (err != CHIP_NO_ERROR) + { + ChipLogError(ICD, "Generation of new key failed: %" CHIP_ERROR_FORMAT, err.Format()); + return nullptr; + } + + auto refreshKeySender = Platform::New(this, clientInfo, clientStorage, newKey); + if (refreshKeySender == nullptr) + { + return nullptr; + } + return refreshKeySender; +} + +void DefaultCheckInDelegate::OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) +{ + if (error == CHIP_NO_ERROR) + { + ChipLogProgress(ICD, "Re-registration with new key completed successfully"); + } + else + { + ChipLogError(ICD, "Re-registration with new key failed with error : %" CHIP_ERROR_FORMAT, error.Format()); + // The callee can take corrective action based on the error received. + } + if (refreshKeySender != nullptr) + { + Platform::Delete(refreshKeySender); + refreshKeySender = nullptr; + } +} } // namespace app } // namespace chip diff --git a/src/app/icd/client/DefaultCheckInDelegate.h b/src/app/icd/client/DefaultCheckInDelegate.h index 5e77186b3c7c9d..e7b856677734bd 100644 --- a/src/app/icd/client/DefaultCheckInDelegate.h +++ b/src/app/icd/client/DefaultCheckInDelegate.h @@ -33,6 +33,8 @@ class DefaultCheckInDelegate : public CheckInDelegate virtual ~DefaultCheckInDelegate() {} CHIP_ERROR Init(ICDClientStorage * storage); void OnCheckInComplete(const ICDClientInfo & clientInfo) override; + RefreshKeySender * OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) override; + void OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) override; private: ICDClientStorage * mpStorage = nullptr; diff --git a/src/app/icd/client/RefreshKeySender.cpp b/src/app/icd/client/RefreshKeySender.cpp new file mode 100644 index 00000000000000..45cbbd9c987a68 --- /dev/null +++ b/src/app/icd/client/RefreshKeySender.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 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 "RefreshKeySender.h" +#include "CheckInDelegate.h" +#include "controller/InvokeInteraction.h" +#include +#include +#include +#include +#include + +namespace chip { +namespace app { + +RefreshKeySender::RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDClientInfo & icdClientInfo, + ICDClientStorage * icdClientStorage, const RefreshKeyBuffer & refreshKeyBuffer) : + mICDClientInfo(icdClientInfo), + mpICDClientStorage(icdClientStorage), mpCheckInDelegate(checkInDelegate), mOnConnectedCallback(HandleDeviceConnected, this), + mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) + +{ + mNewKey = refreshKeyBuffer; +} + +CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle) +{ + auto onSuccess = [&](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) { + ChipLogProgress(ICD, "RegisterClient command succeeded"); + CHIP_ERROR error; + + // Update the ICDClientInfo with new key and start counter and store it to persistence + mICDClientInfo.start_icd_counter = dataResponse.ICDCounter; + mICDClientInfo.offset = 0; + mpICDClientStorage->RemoveKey(mICDClientInfo); + error = mpICDClientStorage->SetKey(mICDClientInfo, mNewKey.Span()); + if (error != CHIP_NO_ERROR) + { + ChipLogError(ICD, "Failed to set the new key after re-registration: %" CHIP_ERROR_FORMAT, error.Format()); + mpCheckInDelegate->OnKeyRefreshDone(this, error); + return; + } + + error = mpICDClientStorage->StoreEntry(mICDClientInfo); + if (error != CHIP_NO_ERROR) + { + ChipLogError(ICD, "Failed to store the new key after re-registration: %" CHIP_ERROR_FORMAT, error.Format()); + mpCheckInDelegate->OnKeyRefreshDone(this, error); + return; + } + + mpCheckInDelegate->OnCheckInComplete(mICDClientInfo); + mpCheckInDelegate->OnKeyRefreshDone(this, CHIP_NO_ERROR); + }; + + auto onFailure = [&](CHIP_ERROR error) { + ChipLogError(ICD, "RegisterClient command failed: %" CHIP_ERROR_FORMAT, error.Format()); + mpCheckInDelegate->OnKeyRefreshDone(this, error); + }; + + EndpointId endpointId = 0; + + Clusters::IcdManagement::Commands::RegisterClient::Type registerClientCommand; + registerClientCommand.checkInNodeID = mICDClientInfo.peer_node.GetNodeId(); + registerClientCommand.monitoredSubject = mICDClientInfo.monitored_subject; + registerClientCommand.key = mNewKey.Span(); + return Controller::InvokeCommandRequest(&exchangeMgr, sessionHandle, endpointId, registerClientCommand, onSuccess, onFailure); +} + +CHIP_ERROR RefreshKeySender::EstablishSessionToPeer() +{ + ChipLogProgress(ICD, "Trying to establish a CASE session for re-registering an ICD client"); + auto * caseSessionManager = InteractionModelEngine::GetInstance()->GetCASESessionManager(); + VerifyOrReturnError(caseSessionManager != nullptr, CHIP_ERROR_INVALID_CASE_PARAMETER); + caseSessionManager->FindOrEstablishSession(mICDClientInfo.peer_node, &mOnConnectedCallback, &mOnConnectionFailureCallback); + return CHIP_NO_ERROR; +} + +void RefreshKeySender::HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, + const SessionHandle & sessionHandle) +{ + RefreshKeySender * const _this = static_cast(context); + VerifyOrDie(_this != nullptr); + + CHIP_ERROR err = _this->RegisterClientWithNewKey(exchangeMgr, sessionHandle); + if (CHIP_NO_ERROR != err) + { + ChipLogError(ICD, "Failed to send register client command"); + _this->mpCheckInDelegate->OnKeyRefreshDone(_this, err); + } +} + +void RefreshKeySender::HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR err) +{ + RefreshKeySender * const _this = static_cast(context); + VerifyOrDie(_this != nullptr); + + ChipLogError(ICD, "Failed to establish CASE for re-registration with error '%" CHIP_ERROR_FORMAT "'", err.Format()); + _this->mpCheckInDelegate->OnKeyRefreshDone(_this, err); +} +} // namespace app +} // namespace chip diff --git a/src/app/icd/client/RefreshKeySender.h b/src/app/icd/client/RefreshKeySender.h new file mode 100644 index 00000000000000..a0cf822fa446f9 --- /dev/null +++ b/src/app/icd/client/RefreshKeySender.h @@ -0,0 +1,93 @@ +/* + * + * Copyright (c) 2024 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. + */ + +#pragma once + +#include "ICDClientInfo.h" +#include "ICDClientStorage.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace chip { +namespace app { + +class CheckInDelegate; + +/** + * @brief RefreshKeySender contains all the data and methods needed for key refresh and re-registration of an ICD client. + */ +class RefreshKeySender +{ +public: + typedef Crypto::SensitiveDataBuffer RefreshKeyBuffer; + + RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDClientInfo & icdClientInfo, ICDClientStorage * icdClientStorage, + const RefreshKeyBuffer & refreshKeyBuffer); + + /** + * @brief Sets up a CASE session to the peer for re-registering a client with the peer when a key refresh is required to avoid + * ICD counter rollover. Returns error if we did not even manage to kick off a CASE attempt. + */ + CHIP_ERROR EstablishSessionToPeer(); + +private: + // CASE session callbacks + /** + * @brief Callback received on successfully establishing a CASE session in order to re-register the client with the peer node + * using a new key to avoid counter rollover problems. + * + * @param[in] context - context of the client establishing the CASE session + * @param[in] exchangeMgr - exchange manager to use for the re-registration + * @param[in] sessionHandle - session handle to use for the re-registration + */ + static void HandleDeviceConnected(void * context, Messaging::ExchangeManager & exchangeMgr, + const SessionHandle & sessionHandle); + /** + * @brief Callback received on failure to establish a CASE session in order to re-register the client with the peer node using a + * new key to avoid counter rollover problems. + * + * @param[in] context - context of the client establishing the CASE session + * @param[in] peerId - Scoped Node ID of the peer node + * @param[in] err - failure reason + */ + static void HandleDeviceConnectionFailure(void * context, const ScopedNodeId & peerId, CHIP_ERROR err); + + /** + * @brief Used to send a re-registration command to the peer using a new key. + * + * @param[in] exchangeMgr - exchange manager to use for the re-registration + * @param[in] sessionHandle - session handle to use for the re-registration + */ + CHIP_ERROR RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle); + + ICDClientInfo mICDClientInfo; + ICDClientStorage * mpICDClientStorage = nullptr; + CheckInDelegate * mpCheckInDelegate = nullptr; + RefreshKeyBuffer mNewKey; + Callback::Callback mOnConnectedCallback; + Callback::Callback mOnConnectionFailureCallback; +}; +} // namespace app +} // namespace chip 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 9943bc6992a016..66fcb0d9b48821 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 @@ -2393,4 +2393,22 @@ limitations under the License. + + Energy EVSE + CHIP + Matter EVSE + Simple + 0x0103 + 0x050C + + + + + + + + + + + diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 29f055560527d6..b02e93ba48c8a7 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -104,7 +104,8 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( #endif jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, - bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure) + bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, + bool skipAttestationCertificateValidation, CHIP_ERROR * errInfoOnFailure) { if (errInfoOnFailure == nullptr) { @@ -168,8 +169,15 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew( #endif // Initialize device attestation verifier - const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); - chip::Credentials::SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + if (skipAttestationCertificateValidation) + { + chip::Credentials::SetDeviceAttestationVerifier(wrapper->GetPartialDACVerifier()); + } + else + { + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + chip::Credentials::SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + } *errInfoOnFailure = wrapper->mICDClientStorage.Init(wrapperStorage, &wrapper->mSessionKeystore); if (*errInfoOnFailure != CHIP_NO_ERROR) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 69a7fe75c0bf0b..d5b07cf7164a75 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -184,7 +184,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, - bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure); + bool skipCommissioningComplete, bool skipAttestationCertificateValidation, CHIP_ERROR * errInfoOnFailure); void Shutdown(); diff --git a/src/controller/java/CHIPDefaultCallbacks.cpp b/src/controller/java/CHIPDefaultCallbacks.cpp deleted file mode 100644 index 4600c5c9877a14..00000000000000 --- a/src/controller/java/CHIPDefaultCallbacks.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "CHIPDefaultCallbacks.h" -#include "AndroidClusterExceptions.h" - -#include -#include -#include -#include - -chip::CHIPDefaultSuccessCallback::CHIPDefaultSuccessCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -chip::CHIPDefaultSuccessCallback::~CHIPDefaultSuccessCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void chip::CHIPDefaultSuccessCallback::CallbackFn(void * context) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - jmethodID javaMethod; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - CHIPDefaultSuccessCallback * cppCallback = nullptr; - - VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - - cppCallback = reinterpret_cast(context); - VerifyOrExit(cppCallback != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback->javaCallbackRef; - VerifyOrExit(javaCallbackRef != nullptr, err = CHIP_NO_ERROR); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "()V", &javaMethod); - SuccessOrExit(err); - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod); - -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error invoking Java callback: %" CHIP_ERROR_FORMAT, err.Format()); - } - if (cppCallback != nullptr) - { - cppCallback->Cancel(); - delete cppCallback; - } -} - -chip::CHIPDefaultFailureCallback::CHIPDefaultFailureCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -chip::CHIPDefaultFailureCallback::~CHIPDefaultFailureCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void chip::CHIPDefaultFailureCallback::CallbackFn(void * context, CHIP_ERROR error) -{ - chip::app::StatusIB status(error); - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - jmethodID javaMethod; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceScope scope(env); - - jobject javaCallbackRef; - jthrowable exception; - CHIPDefaultFailureCallback * cppCallback = nullptr; - - VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - - cppCallback = reinterpret_cast(context); - VerifyOrExit(cppCallback != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback->javaCallbackRef; - VerifyOrExit(javaCallbackRef != nullptr, err = CHIP_NO_ERROR); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onError", "(Ljava/lang/Exception;)V", &javaMethod); - SuccessOrExit(err); - - // TODO: Figure out what to do with the non-StatusIB cases and the cases - // when we have a cluster status? - err = chip::AndroidClusterExceptions::GetInstance().CreateChipClusterException(env, chip::to_underlying(status.mStatus), - exception); - SuccessOrExit(err); - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, exception); -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error invoking Java callback: %" CHIP_ERROR_FORMAT, err.Format()); - } - if (cppCallback != nullptr) - { - cppCallback->Cancel(); - delete cppCallback; - } -} diff --git a/src/controller/java/CHIPDefaultCallbacks.h b/src/controller/java/CHIPDefaultCallbacks.h deleted file mode 100644 index 8256bf6a38e035..00000000000000 --- a/src/controller/java/CHIPDefaultCallbacks.h +++ /dev/null @@ -1,38 +0,0 @@ -#include - -#include -#include - -#include - -namespace chip { - -/** A success callback that delegates to the Java DefaultClusterCallback.onSuccess(). */ -class CHIPDefaultSuccessCallback : public Callback::Callback -{ -public: - CHIPDefaultSuccessCallback(jobject javaCallback); - - ~CHIPDefaultSuccessCallback(); - - static void CallbackFn(void * context); - -private: - jobject javaCallbackRef; -}; - -/** A failure callback that delegates to the Java DefaultClusterCallback.onError(). */ -class CHIPDefaultFailureCallback : public Callback::Callback -{ -public: - CHIPDefaultFailureCallback(jobject javaCallback); - - ~CHIPDefaultFailureCallback(); - - static void CallbackFn(void * context, CHIP_ERROR error); - -private: - jobject javaCallbackRef; -}; - -} // namespace chip diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index b32c207fcf92f9..1d3cd938c16ca0 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -323,6 +323,11 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr &getSkipCommissioningComplete); SuccessOrExit(err); + jmethodID getSkipAttestationCertificateValidation; + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getSkipAttestationCertificateValidation", "()Z", + &getSkipAttestationCertificateValidation); + SuccessOrExit(err); + jmethodID getCountryCode; err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getCountryCode", "()Ljava/util/Optional;", &getCountryCode); @@ -372,9 +377,11 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr uint16_t failsafeTimerSeconds = static_cast(env->CallIntMethod(controllerParams, getFailsafeTimerSeconds)); uint16_t caseFailsafeTimerSeconds = static_cast(env->CallIntMethod(controllerParams, getCASEFailsafeTimerSeconds)); - bool attemptNetworkScanWiFi = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanWiFi); - bool attemptNetworkScanThread = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanThread); - bool skipCommissioningComplete = env->CallBooleanMethod(controllerParams, getSkipCommissioningComplete); + bool attemptNetworkScanWiFi = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanWiFi); + bool attemptNetworkScanThread = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanThread); + bool skipCommissioningComplete = env->CallBooleanMethod(controllerParams, getSkipCommissioningComplete); + bool skipAttestationCertificateValidation = + env->CallBooleanMethod(controllerParams, getSkipAttestationCertificateValidation); uint64_t adminSubject = static_cast(env->CallLongMethod(controllerParams, getAdminSubject)); jobject countryCodeOptional = env->CallObjectMethod(controllerParams, getCountryCode); jobject regulatoryLocationOptional = env->CallObjectMethod(controllerParams, getRegulatoryLocation); @@ -390,7 +397,8 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr sJVM, self, kLocalDeviceId, fabricId, chip::kUndefinedCATs, &DeviceLayer::SystemLayer(), DeviceLayer::TCPEndPointManager(), DeviceLayer::UDPEndPointManager(), std::move(opCredsIssuer), keypairDelegate, rootCertificate, intermediateCertificate, operationalCertificate, ipk, listenPort, controllerVendorId, - failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, skipCommissioningComplete, &err); + failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, skipCommissioningComplete, + skipAttestationCertificateValidation, &err); SuccessOrExit(err); if (caseFailsafeTimerSeconds > 0) @@ -2156,6 +2164,33 @@ JNI_METHOD(jobject, computePaseVerifier) return nullptr; } +JNI_METHOD(jbyteArray, validateAndExtractCSR)(JNIEnv * env, jclass clazz, jbyteArray jCsrElements, jbyteArray jCsrNonce) +{ + + chip::JniByteArray csrElements(env, jCsrElements); + chip::JniByteArray csrNonce(env, jCsrNonce); + + chip::ByteSpan csrSpan; + chip::ByteSpan csrNonceSpan; + chip::ByteSpan vendor_reserved1, vendor_reserved2, vendor_reserved3; + CHIP_ERROR err = chip::Credentials::DeconstructNOCSRElements(csrElements.byteSpan(), csrSpan, csrNonceSpan, vendor_reserved1, + vendor_reserved2, vendor_reserved3); + + VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, + ChipLogError(Controller, "CsrElement decoding error: %" CHIP_ERROR_FORMAT, err.Format())); + VerifyOrReturnValue(csrNonceSpan.size() == Controller::kCSRNonceLength, nullptr, + ChipLogError(Controller, "csrNonce size is invalid")); + + // Verify that Nonce matches with what we sent + VerifyOrReturnValue(csrNonceSpan.data_equal(csrNonce.byteSpan()), nullptr, + ChipLogError(Controller, "csrNonce is not matched!")); + + jbyteArray javaCsr; + chip::JniReferences::GetInstance().N2J_ByteArray(chip::JniReferences::GetInstance().GetEnvForCurrentThread(), csrSpan.data(), + static_cast(csrSpan.size()), javaCsr); + return javaCsr; +} + JNI_METHOD(jobject, getICDClientInfo)(JNIEnv * env, jobject self, jlong handle, jint jFabricIndex) { chip::DeviceLayer::StackLock lock; diff --git a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java index 6f70ad885ec9b7..bbf247b09e5a9d 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java @@ -1326,6 +1326,8 @@ public void shutdownCommissioning() { shutdownCommissioning(deviceControllerPtr); } + public static native byte[] validateAndExtractCSR(byte[] csrElements, byte[] csrNonce); + private native PaseVerifierParams computePaseVerifier( long deviceControllerPtr, long devicePtr, long setupPincode, long iterations, byte[] salt); diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index c52147f73b83b1..ca41cf900902af 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -14,6 +14,7 @@ public final class ControllerParams { private final boolean attemptNetworkScanWiFi; private final boolean attemptNetworkScanThread; private final boolean skipCommissioningComplete; + private final boolean skipAttestationCertificateValidation; private final Optional countryCode; private final Optional regulatoryLocationType; @Nullable private final KeypairDelegate keypairDelegate; @@ -33,6 +34,7 @@ private ControllerParams(Builder builder) { this.attemptNetworkScanWiFi = builder.attemptNetworkScanWiFi; this.attemptNetworkScanThread = builder.attemptNetworkScanThread; this.skipCommissioningComplete = builder.skipCommissioningComplete; + this.skipAttestationCertificateValidation = builder.skipAttestationCertificateValidation; this.countryCode = builder.countryCode; this.regulatoryLocationType = builder.regulatoryLocationType; this.keypairDelegate = builder.keypairDelegate; @@ -76,6 +78,10 @@ public boolean getSkipCommissioningComplete() { return skipCommissioningComplete; } + public boolean getSkipAttestationCertificateValidation() { + return skipAttestationCertificateValidation; + } + public Optional getCountryCode() { return countryCode; } @@ -137,6 +143,7 @@ public static class Builder { private boolean attemptNetworkScanWiFi = false; private boolean attemptNetworkScanThread = false; private boolean skipCommissioningComplete = false; + private boolean skipAttestationCertificateValidation = false; private Optional countryCode = Optional.empty(); private Optional regulatoryLocationType = Optional.empty(); @Nullable private KeypairDelegate keypairDelegate = null; @@ -257,6 +264,21 @@ public Builder setSkipCommissioningComplete(boolean skipCommissioningComplete) { return this; } + /** + * Used when the Commissioner disables Attestation Certificate Validation. + * + *

Specifically, this sets SkipAttestationCertificateValidation in the + * CommissioningParameters passed to the CommissioningDelegate. + * + * @param skipAttestationCertificateValidation + * @return + */ + public Builder setSkipAttestationCertificateValidation( + boolean skipAttestationCertificateValidation) { + this.skipAttestationCertificateValidation = skipAttestationCertificateValidation; + return this; + } + /** * Sets the Regulatory Location country code passed to ChipDeviceCommissioner's * CommissioningParameters. diff --git a/src/controller/java/templates/partials/encode_value.zapt b/src/controller/java/templates/partials/encode_value.zapt deleted file mode 100644 index 3f6d573662ba9f..00000000000000 --- a/src/controller/java/templates/partials/encode_value.zapt +++ /dev/null @@ -1,61 +0,0 @@ -{{#if isOptional}} - if ({{source}} != nullptr) { - jobject optionalValue_{{depth}}; - chip::JniReferences::GetInstance().GetOptionalValue({{source}}, optionalValue_{{depth}}); - if (optionalValue_{{depth}} != nullptr) { - auto & definedValue_{{depth}} = {{target}}.Emplace(); - {{>encode_value target=(concat "definedValue_" depth) source=(concat "optionalValue_" depth) cluster=cluster depth=(incrementDepth depth) isOptional=false}} - } - } -{{else if isNullable}} - if ({{source}} == nullptr) { - {{target}}.SetNull(); - } else { - auto & nonNullValue_{{depth}} = {{target}}.SetNonNull(); - {{>encode_value target=(concat "nonNullValue_" depth) source=source cluster=cluster depth=(incrementDepth depth) isNullable=false}} - } -{{else if isArray}} - { - using ListType_{{depth}} = std::remove_reference_t; - using ListMemberType_{{depth}} = ListMemberTypeGetter::Type; - jint {{source}}Size; - chip::JniReferences::GetInstance().GetListSize({{source}}, {{source}}Size); - if ({{source}}Size != 0) { - auto * listHolder_{{depth}} = new ListHolder({{source}}Size); - listFreer.add(listHolder_{{depth}}); - - for (jint i_{{depth}} = 0; i_{{depth}} < {{source}}Size; ++i_{{depth}}) { - jobject element_{{depth}}; - chip::JniReferences::GetInstance().GetListItem({{source}}, i_{{depth}}, element_{{depth}}); - {{>encode_value target=(concat "listHolder_" depth "->mList[i_" depth "]") source=(concat "element_" depth) cluster=cluster depth=(incrementDepth depth) isArray=false}} - } - {{target}} = ListType_{{depth}}(listHolder_{{depth}}->mList, {{source}}Size); - } else { - {{target}} = ListType_{{depth}}(); - } - } -{{else if (isOctetString type)}} - cleanupByteArrays.push_back(chip::Platform::MakeUnique(env, static_cast({{source}}))); - {{target}} = cleanupByteArrays.back()->byteSpan(); -{{else if (isCharString type)}} - cleanupStrings.push_back(chip::Platform::MakeUnique(env, static_cast({{source}}))); - {{target}} = cleanupStrings.back()->charSpan(); -{{else}} - {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} - jobject {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}; - chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null (asUpperCamelCase ../cluster) true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); - {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "_" (asLowerCamelCase label) "Item_" ../depth) cluster=../cluster depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_and_cluster_name}} - {{else}} - {{#if_chip_enum type}} - {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); - {{else}} - {{#if_is_strongly_typed_bitmap type}} - {{target}}.SetRaw(static_cast::IntegerType>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}}))); - {{else}} - {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); - {{/if_is_strongly_typed_bitmap}} - {{/if_chip_enum}} - {{/if_is_struct}} -{{/if}} diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp deleted file mode 100644 index 81f52531281c3d..00000000000000 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ /dev/null @@ -1,8525 +0,0 @@ -/* - * - * Copyright (c) 2022 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. - */ - -// THIS FILE IS GENERATED BY ZAP -#include "CHIPInvokeCallbacks.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace chip { - -CHIPGroupsClusterAddGroupResponseCallback::CHIPGroupsClusterAddGroupResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterAddGroupResponseCallback::~CHIPGroupsClusterAddGroupResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterAddGroupResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); -} -CHIPGroupsClusterViewGroupResponseCallback::CHIPGroupsClusterViewGroupResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterViewGroupResponseCallback::~CHIPGroupsClusterViewGroupResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterViewGroupResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject GroupName; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.groupName, GroupName)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, GroupName); -} -CHIPGroupsClusterGetGroupMembershipResponseCallback::CHIPGroupsClusterGetGroupMembershipResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterGetGroupMembershipResponseCallback::~CHIPGroupsClusterGetGroupMembershipResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterGetGroupMembershipResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Capacity; - if (dataResponse.capacity.IsNull()) - { - Capacity = nullptr; - } - else - { - std::string CapacityClassName = "java/lang/Integer"; - std::string CapacityCtorSignature = "(I)V"; - jint jniCapacity = static_cast(dataResponse.capacity.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CapacityClassName.c_str(), CapacityCtorSignature.c_str(), - jniCapacity, Capacity); - } - jobject GroupList; - chip::JniReferences::GetInstance().CreateArrayList(GroupList); - - auto iter_GroupList_0 = dataResponse.groupList.begin(); - while (iter_GroupList_0.Next()) - { - auto & entry_0 = iter_GroupList_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint 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(GroupList, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Capacity, GroupList); -} -CHIPGroupsClusterRemoveGroupResponseCallback::CHIPGroupsClusterRemoveGroupResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupsClusterRemoveGroupResponseCallback::~CHIPGroupsClusterRemoveGroupResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupsClusterRemoveGroupResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); -} -CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::~CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject DelayedActionTime; - if (!dataResponse.delayedActionTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DelayedActionTime); - } - else - { - jobject DelayedActionTimeInsideOptional; - std::string DelayedActionTimeInsideOptionalClassName = "java/lang/Long"; - std::string DelayedActionTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniDelayedActionTimeInsideOptional = static_cast(dataResponse.delayedActionTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - DelayedActionTimeInsideOptionalClassName.c_str(), DelayedActionTimeInsideOptionalCtorSignature.c_str(), - jniDelayedActionTimeInsideOptional, DelayedActionTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(DelayedActionTimeInsideOptional, DelayedActionTime); - } - jobject ImageURI; - if (!dataResponse.imageURI.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ImageURI); - } - else - { - jobject ImageURIInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.imageURI.Value(), ImageURIInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(ImageURIInsideOptional, ImageURI); - } - jobject SoftwareVersion; - if (!dataResponse.softwareVersion.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SoftwareVersion); - } - else - { - jobject SoftwareVersionInsideOptional; - std::string SoftwareVersionInsideOptionalClassName = "java/lang/Long"; - std::string SoftwareVersionInsideOptionalCtorSignature = "(J)V"; - jlong jniSoftwareVersionInsideOptional = static_cast(dataResponse.softwareVersion.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - SoftwareVersionInsideOptionalClassName.c_str(), SoftwareVersionInsideOptionalCtorSignature.c_str(), - jniSoftwareVersionInsideOptional, SoftwareVersionInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionInsideOptional, SoftwareVersion); - } - jobject SoftwareVersionString; - if (!dataResponse.softwareVersionString.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SoftwareVersionString); - } - else - { - jobject SoftwareVersionStringInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.softwareVersionString.Value(), - SoftwareVersionStringInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionStringInsideOptional, SoftwareVersionString); - } - jobject UpdateToken; - if (!dataResponse.updateToken.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, UpdateToken); - } - else - { - jobject UpdateTokenInsideOptional; - jbyteArray UpdateTokenInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.updateToken.Value().size())); - env->SetByteArrayRegion(UpdateTokenInsideOptionalByteArray, 0, static_cast(dataResponse.updateToken.Value().size()), - reinterpret_cast(dataResponse.updateToken.Value().data())); - UpdateTokenInsideOptional = UpdateTokenInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(UpdateTokenInsideOptional, UpdateToken); - } - jobject UserConsentNeeded; - if (!dataResponse.userConsentNeeded.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, UserConsentNeeded); - } - else - { - jobject UserConsentNeededInsideOptional; - std::string UserConsentNeededInsideOptionalClassName = "java/lang/Boolean"; - std::string UserConsentNeededInsideOptionalCtorSignature = "(Z)V"; - jboolean jniUserConsentNeededInsideOptional = static_cast(dataResponse.userConsentNeeded.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - UserConsentNeededInsideOptionalClassName.c_str(), UserConsentNeededInsideOptionalCtorSignature.c_str(), - jniUserConsentNeededInsideOptional, UserConsentNeededInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(UserConsentNeededInsideOptional, UserConsentNeeded); - } - jobject MetadataForRequestor; - if (!dataResponse.metadataForRequestor.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, MetadataForRequestor); - } - else - { - jobject MetadataForRequestorInsideOptional; - jbyteArray MetadataForRequestorInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.metadataForRequestor.Value().size())); - env->SetByteArrayRegion(MetadataForRequestorInsideOptionalByteArray, 0, - static_cast(dataResponse.metadataForRequestor.Value().size()), - reinterpret_cast(dataResponse.metadataForRequestor.Value().data())); - MetadataForRequestorInsideOptional = MetadataForRequestorInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(MetadataForRequestorInsideOptional, MetadataForRequestor); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, DelayedActionTime, ImageURI, SoftwareVersion, SoftwareVersionString, - UpdateToken, UserConsentNeeded, MetadataForRequestor); -} -CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::~CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Long;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Action; - std::string ActionClassName = "java/lang/Integer"; - std::string ActionCtorSignature = "(I)V"; - jint jniAction = static_cast(dataResponse.action); - chip::JniReferences::GetInstance().CreateBoxedObject(ActionClassName.c_str(), ActionCtorSignature.c_str(), jniAction, - Action); - jobject DelayedActionTime; - std::string DelayedActionTimeClassName = "java/lang/Long"; - std::string DelayedActionTimeCtorSignature = "(J)V"; - jlong jniDelayedActionTime = static_cast(dataResponse.delayedActionTime); - chip::JniReferences::GetInstance().CreateBoxedObject( - DelayedActionTimeClassName.c_str(), DelayedActionTimeCtorSignature.c_str(), jniDelayedActionTime, DelayedActionTime); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Action, DelayedActionTime); -} -CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CHIPGeneralCommissioningClusterArmFailSafeResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::~CHIPGeneralCommissioningClusterArmFailSafeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ErrorCode; - std::string ErrorCodeClassName = "java/lang/Integer"; - std::string ErrorCodeCtorSignature = "(I)V"; - jint jniErrorCode = static_cast(dataResponse.errorCode); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), - jniErrorCode, ErrorCode); - jobject DebugText; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); -} -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback:: -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback::~ -CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ErrorCode; - std::string ErrorCodeClassName = "java/lang/Integer"; - std::string ErrorCodeCtorSignature = "(I)V"; - jint jniErrorCode = static_cast(dataResponse.errorCode); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), - jniErrorCode, ErrorCode); - jobject DebugText; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); -} -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback:: -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback::~ -CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ErrorCode; - std::string ErrorCodeClassName = "java/lang/Integer"; - std::string ErrorCodeCtorSignature = "(I)V"; - jint jniErrorCode = static_cast(dataResponse.errorCode); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), - jniErrorCode, ErrorCode); - jobject DebugText; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); -} -CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CHIPNetworkCommissioningClusterScanNetworksResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterScanNetworksResponseCallback::~CHIPNetworkCommissioningClusterScanNetworksResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NetworkingStatus; - std::string NetworkingStatusClassName = "java/lang/Integer"; - std::string NetworkingStatusCtorSignature = "(I)V"; - jint jniNetworkingStatus = static_cast(dataResponse.networkingStatus); - chip::JniReferences::GetInstance().CreateBoxedObject( - NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - jobject WiFiScanResults; - if (!dataResponse.wiFiScanResults.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, WiFiScanResults); - } - else - { - jobject WiFiScanResultsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(WiFiScanResultsInsideOptional); - - auto iter_WiFiScanResultsInsideOptional_1 = dataResponse.wiFiScanResults.Value().begin(); - while (iter_WiFiScanResultsInsideOptional_1.Next()) - { - auto & entry_1 = iter_WiFiScanResultsInsideOptional_1.GetValue(); - jobject newElement_1; - jobject newElement_1_security; - std::string newElement_1_securityClassName = "java/lang/Integer"; - std::string newElement_1_securityCtorSignature = "(I)V"; - jint jninewElement_1_security = static_cast(entry_1.security.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_securityClassName.c_str(), - newElement_1_securityCtorSignature.c_str(), - jninewElement_1_security, newElement_1_security); - jobject newElement_1_ssid; - jbyteArray newElement_1_ssidByteArray = env->NewByteArray(static_cast(entry_1.ssid.size())); - env->SetByteArrayRegion(newElement_1_ssidByteArray, 0, static_cast(entry_1.ssid.size()), - reinterpret_cast(entry_1.ssid.data())); - newElement_1_ssid = newElement_1_ssidByteArray; - jobject newElement_1_bssid; - jbyteArray newElement_1_bssidByteArray = env->NewByteArray(static_cast(entry_1.bssid.size())); - env->SetByteArrayRegion(newElement_1_bssidByteArray, 0, static_cast(entry_1.bssid.size()), - reinterpret_cast(entry_1.bssid.data())); - newElement_1_bssid = newElement_1_bssidByteArray; - jobject newElement_1_channel; - std::string newElement_1_channelClassName = "java/lang/Integer"; - std::string newElement_1_channelCtorSignature = "(I)V"; - jint jninewElement_1_channel = static_cast(entry_1.channel); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_channelClassName.c_str(), - newElement_1_channelCtorSignature.c_str(), - jninewElement_1_channel, newElement_1_channel); - jobject newElement_1_wiFiBand; - std::string newElement_1_wiFiBandClassName = "java/lang/Integer"; - std::string newElement_1_wiFiBandCtorSignature = "(I)V"; - jint jninewElement_1_wiFiBand = static_cast(entry_1.wiFiBand); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_wiFiBandClassName.c_str(), - newElement_1_wiFiBandCtorSignature.c_str(), - jninewElement_1_wiFiBand, newElement_1_wiFiBand); - jobject newElement_1_rssi; - std::string newElement_1_rssiClassName = "java/lang/Integer"; - std::string newElement_1_rssiCtorSignature = "(I)V"; - jint jninewElement_1_rssi = static_cast(entry_1.rssi); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_rssiClassName.c_str(), - newElement_1_rssiCtorSignature.c_str(), jninewElement_1_rssi, - newElement_1_rssi); - - jclass wiFiInterfaceScanResultStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct", - wiFiInterfaceScanResultStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct"); - return; - } - - jmethodID wiFiInterfaceScanResultStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod( - env, wiFiInterfaceScanResultStructStructClass_2, "", - "(Ljava/lang/Integer;[B[BLjava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", - &wiFiInterfaceScanResultStructStructCtor_2); - if (err != CHIP_NO_ERROR || wiFiInterfaceScanResultStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, - "Could not find ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct constructor"); - return; - } - - newElement_1 = env->NewObject(wiFiInterfaceScanResultStructStructClass_2, wiFiInterfaceScanResultStructStructCtor_2, - newElement_1_security, newElement_1_ssid, newElement_1_bssid, newElement_1_channel, - newElement_1_wiFiBand, newElement_1_rssi); - chip::JniReferences::GetInstance().AddToList(WiFiScanResultsInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(WiFiScanResultsInsideOptional, WiFiScanResults); - } - jobject ThreadScanResults; - if (!dataResponse.threadScanResults.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ThreadScanResults); - } - else - { - jobject ThreadScanResultsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(ThreadScanResultsInsideOptional); - - auto iter_ThreadScanResultsInsideOptional_1 = dataResponse.threadScanResults.Value().begin(); - while (iter_ThreadScanResultsInsideOptional_1.Next()) - { - auto & entry_1 = iter_ThreadScanResultsInsideOptional_1.GetValue(); - jobject newElement_1; - jobject newElement_1_panId; - std::string newElement_1_panIdClassName = "java/lang/Integer"; - std::string newElement_1_panIdCtorSignature = "(I)V"; - jint jninewElement_1_panId = static_cast(entry_1.panId); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_panIdClassName.c_str(), - newElement_1_panIdCtorSignature.c_str(), - jninewElement_1_panId, newElement_1_panId); - jobject newElement_1_extendedPanId; - std::string newElement_1_extendedPanIdClassName = "java/lang/Long"; - std::string newElement_1_extendedPanIdCtorSignature = "(J)V"; - jlong jninewElement_1_extendedPanId = static_cast(entry_1.extendedPanId); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_extendedPanIdClassName.c_str(), - newElement_1_extendedPanIdCtorSignature.c_str(), - jninewElement_1_extendedPanId, newElement_1_extendedPanId); - jobject newElement_1_networkName; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_1.networkName, newElement_1_networkName)); - jobject newElement_1_channel; - std::string newElement_1_channelClassName = "java/lang/Integer"; - std::string newElement_1_channelCtorSignature = "(I)V"; - jint jninewElement_1_channel = static_cast(entry_1.channel); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_channelClassName.c_str(), - newElement_1_channelCtorSignature.c_str(), - jninewElement_1_channel, newElement_1_channel); - jobject newElement_1_version; - std::string newElement_1_versionClassName = "java/lang/Integer"; - std::string newElement_1_versionCtorSignature = "(I)V"; - jint jninewElement_1_version = static_cast(entry_1.version); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_versionClassName.c_str(), - newElement_1_versionCtorSignature.c_str(), - jninewElement_1_version, newElement_1_version); - jobject newElement_1_extendedAddress; - jbyteArray newElement_1_extendedAddressByteArray = - env->NewByteArray(static_cast(entry_1.extendedAddress.size())); - env->SetByteArrayRegion(newElement_1_extendedAddressByteArray, 0, static_cast(entry_1.extendedAddress.size()), - reinterpret_cast(entry_1.extendedAddress.data())); - newElement_1_extendedAddress = newElement_1_extendedAddressByteArray; - jobject newElement_1_rssi; - std::string newElement_1_rssiClassName = "java/lang/Integer"; - std::string newElement_1_rssiCtorSignature = "(I)V"; - jint jninewElement_1_rssi = static_cast(entry_1.rssi); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_rssiClassName.c_str(), - newElement_1_rssiCtorSignature.c_str(), jninewElement_1_rssi, - newElement_1_rssi); - jobject newElement_1_lqi; - std::string newElement_1_lqiClassName = "java/lang/Integer"; - std::string newElement_1_lqiCtorSignature = "(I)V"; - jint jninewElement_1_lqi = static_cast(entry_1.lqi); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1_lqiClassName.c_str(), newElement_1_lqiCtorSignature.c_str(), jninewElement_1_lqi, newElement_1_lqi); - - jclass threadInterfaceScanResultStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct", - threadInterfaceScanResultStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct"); - return; - } - - jmethodID threadInterfaceScanResultStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod( - env, threadInterfaceScanResultStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;[BLjava/lang/" - "Integer;Ljava/lang/Integer;)V", - &threadInterfaceScanResultStructStructCtor_2); - if (err != CHIP_NO_ERROR || threadInterfaceScanResultStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, - "Could not find ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct constructor"); - return; - } - - newElement_1 = - env->NewObject(threadInterfaceScanResultStructStructClass_2, threadInterfaceScanResultStructStructCtor_2, - newElement_1_panId, newElement_1_extendedPanId, newElement_1_networkName, newElement_1_channel, - newElement_1_version, newElement_1_extendedAddress, newElement_1_rssi, newElement_1_lqi); - chip::JniReferences::GetInstance().AddToList(ThreadScanResultsInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(ThreadScanResultsInsideOptional, ThreadScanResults); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); -} -CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CHIPNetworkCommissioningClusterNetworkConfigResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::~CHIPNetworkCommissioningClusterNetworkConfigResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NetworkingStatus; - std::string NetworkingStatusClassName = "java/lang/Integer"; - std::string NetworkingStatusCtorSignature = "(I)V"; - jint jniNetworkingStatus = static_cast(dataResponse.networkingStatus); - chip::JniReferences::GetInstance().CreateBoxedObject( - NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - jobject NetworkIndex; - if (!dataResponse.networkIndex.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NetworkIndex); - } - else - { - jobject NetworkIndexInsideOptional; - std::string NetworkIndexInsideOptionalClassName = "java/lang/Integer"; - std::string NetworkIndexInsideOptionalCtorSignature = "(I)V"; - jint jniNetworkIndexInsideOptional = static_cast(dataResponse.networkIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(NetworkIndexInsideOptionalClassName.c_str(), - NetworkIndexInsideOptionalCtorSignature.c_str(), - jniNetworkIndexInsideOptional, NetworkIndexInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NetworkIndexInsideOptional, NetworkIndex); - } - jobject ClientIdentity; - if (!dataResponse.clientIdentity.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ClientIdentity); - } - else - { - jobject ClientIdentityInsideOptional; - jbyteArray ClientIdentityInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.clientIdentity.Value().size())); - env->SetByteArrayRegion(ClientIdentityInsideOptionalByteArray, 0, - static_cast(dataResponse.clientIdentity.Value().size()), - reinterpret_cast(dataResponse.clientIdentity.Value().data())); - ClientIdentityInsideOptional = ClientIdentityInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(ClientIdentityInsideOptional, ClientIdentity); - } - jobject PossessionSignature; - if (!dataResponse.possessionSignature.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, PossessionSignature); - } - else - { - jobject PossessionSignatureInsideOptional; - jbyteArray PossessionSignatureInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.possessionSignature.Value().size())); - env->SetByteArrayRegion(PossessionSignatureInsideOptionalByteArray, 0, - static_cast(dataResponse.possessionSignature.Value().size()), - reinterpret_cast(dataResponse.possessionSignature.Value().data())); - PossessionSignatureInsideOptional = PossessionSignatureInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(PossessionSignatureInsideOptional, PossessionSignature); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, NetworkIndex, ClientIdentity, - PossessionSignature); -} -CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CHIPNetworkCommissioningClusterConnectNetworkResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::~CHIPNetworkCommissioningClusterConnectNetworkResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NetworkingStatus; - std::string NetworkingStatusClassName = "java/lang/Integer"; - std::string NetworkingStatusCtorSignature = "(I)V"; - jint jniNetworkingStatus = static_cast(dataResponse.networkingStatus); - chip::JniReferences::GetInstance().CreateBoxedObject( - NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - jobject ErrorValue; - if (dataResponse.errorValue.IsNull()) - { - ErrorValue = nullptr; - } - else - { - std::string ErrorValueClassName = "java/lang/Long"; - std::string ErrorValueCtorSignature = "(J)V"; - jlong jniErrorValue = static_cast(dataResponse.errorValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(ErrorValueClassName.c_str(), ErrorValueCtorSignature.c_str(), - jniErrorValue, ErrorValue); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, ErrorValue); -} -CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::CHIPNetworkCommissioningClusterQueryIdentityResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::~CHIPNetworkCommissioningClusterQueryIdentityResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::NetworkCommissioning::Commands::QueryIdentityResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([BLjava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Identity; - jbyteArray IdentityByteArray = env->NewByteArray(static_cast(dataResponse.identity.size())); - env->SetByteArrayRegion(IdentityByteArray, 0, static_cast(dataResponse.identity.size()), - reinterpret_cast(dataResponse.identity.data())); - Identity = IdentityByteArray; - jobject PossessionSignature; - if (!dataResponse.possessionSignature.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, PossessionSignature); - } - else - { - jobject PossessionSignatureInsideOptional; - jbyteArray PossessionSignatureInsideOptionalByteArray = - env->NewByteArray(static_cast(dataResponse.possessionSignature.Value().size())); - env->SetByteArrayRegion(PossessionSignatureInsideOptionalByteArray, 0, - static_cast(dataResponse.possessionSignature.Value().size()), - reinterpret_cast(dataResponse.possessionSignature.Value().data())); - PossessionSignatureInsideOptional = PossessionSignatureInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(PossessionSignatureInsideOptional, PossessionSignature); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Identity, PossessionSignature); -} -CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::~CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;[BLjava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject LogContent; - jbyteArray LogContentByteArray = env->NewByteArray(static_cast(dataResponse.logContent.size())); - env->SetByteArrayRegion(LogContentByteArray, 0, static_cast(dataResponse.logContent.size()), - reinterpret_cast(dataResponse.logContent.data())); - LogContent = LogContentByteArray; - jobject UTCTimeStamp; - if (!dataResponse.UTCTimeStamp.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, UTCTimeStamp); - } - else - { - jobject UTCTimeStampInsideOptional; - std::string UTCTimeStampInsideOptionalClassName = "java/lang/Long"; - std::string UTCTimeStampInsideOptionalCtorSignature = "(J)V"; - jlong jniUTCTimeStampInsideOptional = static_cast(dataResponse.UTCTimeStamp.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UTCTimeStampInsideOptionalClassName.c_str(), - UTCTimeStampInsideOptionalCtorSignature.c_str(), - jniUTCTimeStampInsideOptional, UTCTimeStampInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(UTCTimeStampInsideOptional, UTCTimeStamp); - } - jobject TimeSinceBoot; - if (!dataResponse.timeSinceBoot.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, TimeSinceBoot); - } - else - { - jobject TimeSinceBootInsideOptional; - std::string TimeSinceBootInsideOptionalClassName = "java/lang/Long"; - std::string TimeSinceBootInsideOptionalCtorSignature = "(J)V"; - jlong jniTimeSinceBootInsideOptional = static_cast(dataResponse.timeSinceBoot.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(TimeSinceBootInsideOptionalClassName.c_str(), - TimeSinceBootInsideOptionalCtorSignature.c_str(), - jniTimeSinceBootInsideOptional, TimeSinceBootInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(TimeSinceBootInsideOptional, TimeSinceBoot); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, LogContent, UTCTimeStamp, TimeSinceBoot); -} -CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::~CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::GeneralDiagnostics::Commands::TimeSnapshotResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;Ljava/lang/Long;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject SystemTimeMs; - std::string SystemTimeMsClassName = "java/lang/Long"; - std::string SystemTimeMsCtorSignature = "(J)V"; - jlong jniSystemTimeMs = static_cast(dataResponse.systemTimeMs); - chip::JniReferences::GetInstance().CreateBoxedObject(SystemTimeMsClassName.c_str(), SystemTimeMsCtorSignature.c_str(), - jniSystemTimeMs, SystemTimeMs); - jobject PosixTimeMs; - if (dataResponse.posixTimeMs.IsNull()) - { - PosixTimeMs = nullptr; - } - else - { - std::string PosixTimeMsClassName = "java/lang/Long"; - std::string PosixTimeMsCtorSignature = "(J)V"; - jlong jniPosixTimeMs = static_cast(dataResponse.posixTimeMs.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(PosixTimeMsClassName.c_str(), PosixTimeMsCtorSignature.c_str(), - jniPosixTimeMs, PosixTimeMs); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, SystemTimeMs, PosixTimeMs); -} -CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::~CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject DSTOffsetRequired; - std::string DSTOffsetRequiredClassName = "java/lang/Boolean"; - std::string DSTOffsetRequiredCtorSignature = "(Z)V"; - jboolean jniDSTOffsetRequired = static_cast(dataResponse.DSTOffsetRequired); - chip::JniReferences::GetInstance().CreateBoxedObject( - DSTOffsetRequiredClassName.c_str(), DSTOffsetRequiredCtorSignature.c_str(), jniDSTOffsetRequired, DSTOffsetRequired); - - env->CallVoidMethod(javaCallbackRef, javaMethod, DSTOffsetRequired); -} -CHIPOperationalCredentialsClusterAttestationResponseCallback::CHIPOperationalCredentialsClusterAttestationResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterAttestationResponseCallback::~CHIPOperationalCredentialsClusterAttestationResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterAttestationResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B[B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject AttestationElements; - jbyteArray AttestationElementsByteArray = env->NewByteArray(static_cast(dataResponse.attestationElements.size())); - env->SetByteArrayRegion(AttestationElementsByteArray, 0, static_cast(dataResponse.attestationElements.size()), - reinterpret_cast(dataResponse.attestationElements.data())); - AttestationElements = AttestationElementsByteArray; - jobject AttestationSignature; - jbyteArray AttestationSignatureByteArray = env->NewByteArray(static_cast(dataResponse.attestationSignature.size())); - env->SetByteArrayRegion(AttestationSignatureByteArray, 0, static_cast(dataResponse.attestationSignature.size()), - reinterpret_cast(dataResponse.attestationSignature.data())); - AttestationSignature = AttestationSignatureByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, AttestationElements, AttestationSignature); -} -CHIPOperationalCredentialsClusterCertificateChainResponseCallback:: -CHIPOperationalCredentialsClusterCertificateChainResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterCertificateChainResponseCallback::~ -CHIPOperationalCredentialsClusterCertificateChainResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterCertificateChainResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Certificate; - jbyteArray CertificateByteArray = env->NewByteArray(static_cast(dataResponse.certificate.size())); - env->SetByteArrayRegion(CertificateByteArray, 0, static_cast(dataResponse.certificate.size()), - reinterpret_cast(dataResponse.certificate.data())); - Certificate = CertificateByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, Certificate); -} -CHIPOperationalCredentialsClusterCSRResponseCallback::CHIPOperationalCredentialsClusterCSRResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterCSRResponseCallback::~CHIPOperationalCredentialsClusterCSRResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterCSRResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B[B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NOCSRElements; - jbyteArray NOCSRElementsByteArray = env->NewByteArray(static_cast(dataResponse.NOCSRElements.size())); - env->SetByteArrayRegion(NOCSRElementsByteArray, 0, static_cast(dataResponse.NOCSRElements.size()), - reinterpret_cast(dataResponse.NOCSRElements.data())); - NOCSRElements = NOCSRElementsByteArray; - jobject AttestationSignature; - jbyteArray AttestationSignatureByteArray = env->NewByteArray(static_cast(dataResponse.attestationSignature.size())); - env->SetByteArrayRegion(AttestationSignatureByteArray, 0, static_cast(dataResponse.attestationSignature.size()), - reinterpret_cast(dataResponse.attestationSignature.data())); - AttestationSignature = AttestationSignatureByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, NOCSRElements, AttestationSignature); -} -CHIPOperationalCredentialsClusterNOCResponseCallback::CHIPOperationalCredentialsClusterNOCResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalCredentialsClusterNOCResponseCallback::~CHIPOperationalCredentialsClusterNOCResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalCredentialsClusterNOCResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject StatusCode; - std::string StatusCodeClassName = "java/lang/Integer"; - std::string StatusCodeCtorSignature = "(I)V"; - jint jniStatusCode = static_cast(dataResponse.statusCode); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusCodeClassName.c_str(), StatusCodeCtorSignature.c_str(), - jniStatusCode, StatusCode); - jobject FabricIndex; - if (!dataResponse.fabricIndex.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, FabricIndex); - } - else - { - jobject FabricIndexInsideOptional; - std::string FabricIndexInsideOptionalClassName = "java/lang/Integer"; - std::string FabricIndexInsideOptionalCtorSignature = "(I)V"; - jint jniFabricIndexInsideOptional = static_cast(dataResponse.fabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(FabricIndexInsideOptionalClassName.c_str(), - FabricIndexInsideOptionalCtorSignature.c_str(), - jniFabricIndexInsideOptional, FabricIndexInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(FabricIndexInsideOptional, FabricIndex); - } - jobject DebugText; - if (!dataResponse.debugText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); - } - else - { - jobject DebugTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, StatusCode, FabricIndex, DebugText); -} -CHIPGroupKeyManagementClusterKeySetReadResponseCallback::CHIPGroupKeyManagementClusterKeySetReadResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupKeyManagementClusterKeySetReadResponseCallback::~CHIPGroupKeyManagementClusterKeySetReadResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupKeyManagementClusterKeySetReadResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeySetStruct;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject GroupKeySet; - jobject GroupKeySet_groupKeySetID; - std::string GroupKeySet_groupKeySetIDClassName = "java/lang/Integer"; - std::string GroupKeySet_groupKeySetIDCtorSignature = "(I)V"; - jint jniGroupKeySet_groupKeySetID = static_cast(dataResponse.groupKeySet.groupKeySetID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_groupKeySetIDClassName.c_str(), - GroupKeySet_groupKeySetIDCtorSignature.c_str(), - jniGroupKeySet_groupKeySetID, GroupKeySet_groupKeySetID); - jobject GroupKeySet_groupKeySecurityPolicy; - std::string GroupKeySet_groupKeySecurityPolicyClassName = "java/lang/Integer"; - std::string GroupKeySet_groupKeySecurityPolicyCtorSignature = "(I)V"; - jint jniGroupKeySet_groupKeySecurityPolicy = static_cast(dataResponse.groupKeySet.groupKeySecurityPolicy); - chip::JniReferences::GetInstance().CreateBoxedObject( - GroupKeySet_groupKeySecurityPolicyClassName.c_str(), GroupKeySet_groupKeySecurityPolicyCtorSignature.c_str(), - jniGroupKeySet_groupKeySecurityPolicy, GroupKeySet_groupKeySecurityPolicy); - jobject GroupKeySet_epochKey0; - if (dataResponse.groupKeySet.epochKey0.IsNull()) - { - GroupKeySet_epochKey0 = nullptr; - } - else - { - jbyteArray GroupKeySet_epochKey0ByteArray = - env->NewByteArray(static_cast(dataResponse.groupKeySet.epochKey0.Value().size())); - env->SetByteArrayRegion(GroupKeySet_epochKey0ByteArray, 0, - static_cast(dataResponse.groupKeySet.epochKey0.Value().size()), - reinterpret_cast(dataResponse.groupKeySet.epochKey0.Value().data())); - GroupKeySet_epochKey0 = GroupKeySet_epochKey0ByteArray; - } - jobject GroupKeySet_epochStartTime0; - if (dataResponse.groupKeySet.epochStartTime0.IsNull()) - { - GroupKeySet_epochStartTime0 = nullptr; - } - else - { - std::string GroupKeySet_epochStartTime0ClassName = "java/lang/Long"; - std::string GroupKeySet_epochStartTime0CtorSignature = "(J)V"; - jlong jniGroupKeySet_epochStartTime0 = static_cast(dataResponse.groupKeySet.epochStartTime0.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_epochStartTime0ClassName.c_str(), - GroupKeySet_epochStartTime0CtorSignature.c_str(), - jniGroupKeySet_epochStartTime0, GroupKeySet_epochStartTime0); - } - jobject GroupKeySet_epochKey1; - if (dataResponse.groupKeySet.epochKey1.IsNull()) - { - GroupKeySet_epochKey1 = nullptr; - } - else - { - jbyteArray GroupKeySet_epochKey1ByteArray = - env->NewByteArray(static_cast(dataResponse.groupKeySet.epochKey1.Value().size())); - env->SetByteArrayRegion(GroupKeySet_epochKey1ByteArray, 0, - static_cast(dataResponse.groupKeySet.epochKey1.Value().size()), - reinterpret_cast(dataResponse.groupKeySet.epochKey1.Value().data())); - GroupKeySet_epochKey1 = GroupKeySet_epochKey1ByteArray; - } - jobject GroupKeySet_epochStartTime1; - if (dataResponse.groupKeySet.epochStartTime1.IsNull()) - { - GroupKeySet_epochStartTime1 = nullptr; - } - else - { - std::string GroupKeySet_epochStartTime1ClassName = "java/lang/Long"; - std::string GroupKeySet_epochStartTime1CtorSignature = "(J)V"; - jlong jniGroupKeySet_epochStartTime1 = static_cast(dataResponse.groupKeySet.epochStartTime1.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_epochStartTime1ClassName.c_str(), - GroupKeySet_epochStartTime1CtorSignature.c_str(), - jniGroupKeySet_epochStartTime1, GroupKeySet_epochStartTime1); - } - jobject GroupKeySet_epochKey2; - if (dataResponse.groupKeySet.epochKey2.IsNull()) - { - GroupKeySet_epochKey2 = nullptr; - } - else - { - jbyteArray GroupKeySet_epochKey2ByteArray = - env->NewByteArray(static_cast(dataResponse.groupKeySet.epochKey2.Value().size())); - env->SetByteArrayRegion(GroupKeySet_epochKey2ByteArray, 0, - static_cast(dataResponse.groupKeySet.epochKey2.Value().size()), - reinterpret_cast(dataResponse.groupKeySet.epochKey2.Value().data())); - GroupKeySet_epochKey2 = GroupKeySet_epochKey2ByteArray; - } - jobject GroupKeySet_epochStartTime2; - if (dataResponse.groupKeySet.epochStartTime2.IsNull()) - { - GroupKeySet_epochStartTime2 = nullptr; - } - else - { - std::string GroupKeySet_epochStartTime2ClassName = "java/lang/Long"; - std::string GroupKeySet_epochStartTime2CtorSignature = "(J)V"; - jlong jniGroupKeySet_epochStartTime2 = static_cast(dataResponse.groupKeySet.epochStartTime2.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupKeySet_epochStartTime2ClassName.c_str(), - GroupKeySet_epochStartTime2CtorSignature.c_str(), - jniGroupKeySet_epochStartTime2, GroupKeySet_epochStartTime2); - } - - jclass groupKeySetStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeySetStruct", groupKeySetStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$GroupKeyManagementClusterGroupKeySetStruct"); - return; - } - - jmethodID groupKeySetStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod( - env, groupKeySetStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;[BLjava/lang/Long;[BLjava/lang/Long;[BLjava/lang/Long;)V", - &groupKeySetStructStructCtor_0); - if (err != CHIP_NO_ERROR || groupKeySetStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$GroupKeyManagementClusterGroupKeySetStruct constructor"); - return; - } - - GroupKeySet = - env->NewObject(groupKeySetStructStructClass_0, groupKeySetStructStructCtor_0, GroupKeySet_groupKeySetID, - GroupKeySet_groupKeySecurityPolicy, GroupKeySet_epochKey0, GroupKeySet_epochStartTime0, - GroupKeySet_epochKey1, GroupKeySet_epochStartTime1, GroupKeySet_epochKey2, GroupKeySet_epochStartTime2); - - env->CallVoidMethod(javaCallbackRef, javaMethod, GroupKeySet); -} -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback:: -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback::~ -CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject GroupKeySetIDs; - chip::JniReferences::GetInstance().CreateArrayList(GroupKeySetIDs); - - auto iter_GroupKeySetIDs_0 = dataResponse.groupKeySetIDs.begin(); - while (iter_GroupKeySetIDs_0.Next()) - { - auto & entry_0 = iter_GroupKeySetIDs_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint 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(GroupKeySetIDs, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, GroupKeySetIDs); -} -CHIPIcdManagementClusterRegisterClientResponseCallback::CHIPIcdManagementClusterRegisterClientResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPIcdManagementClusterRegisterClientResponseCallback::~CHIPIcdManagementClusterRegisterClientResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPIcdManagementClusterRegisterClientResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::IcdManagement::Commands::RegisterClientResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ICDCounter; - std::string ICDCounterClassName = "java/lang/Long"; - std::string ICDCounterCtorSignature = "(J)V"; - jlong jniICDCounter = static_cast(dataResponse.ICDCounter); - chip::JniReferences::GetInstance().CreateBoxedObject(ICDCounterClassName.c_str(), ICDCounterCtorSignature.c_str(), - jniICDCounter, ICDCounter); - - env->CallVoidMethod(javaCallbackRef, javaMethod, ICDCounter); -} -CHIPIcdManagementClusterStayActiveResponseCallback::CHIPIcdManagementClusterStayActiveResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPIcdManagementClusterStayActiveResponseCallback::~CHIPIcdManagementClusterStayActiveResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPIcdManagementClusterStayActiveResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::IcdManagement::Commands::StayActiveResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject PromisedActiveDuration; - std::string PromisedActiveDurationClassName = "java/lang/Long"; - std::string PromisedActiveDurationCtorSignature = "(J)V"; - jlong jniPromisedActiveDuration = static_cast(dataResponse.promisedActiveDuration); - chip::JniReferences::GetInstance().CreateBoxedObject(PromisedActiveDurationClassName.c_str(), - PromisedActiveDurationCtorSignature.c_str(), - jniPromisedActiveDuration, PromisedActiveDuration); - - env->CallVoidMethod(javaCallbackRef, javaMethod, PromisedActiveDuration); -} -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback:: -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback::~ -CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::OvenCavityOperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Lchip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CommandResponseState; - jobject CommandResponseState_errorStateID; - std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; - std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; - jint jniCommandResponseState_errorStateID = static_cast(dataResponse.commandResponseState.errorStateID); - chip::JniReferences::GetInstance().CreateBoxedObject( - CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), - jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); - jobject CommandResponseState_errorStateLabel; - if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); - } - else - { - jobject CommandResponseState_errorStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, - CommandResponseState_errorStateLabel); - } - jobject CommandResponseState_errorStateDetails; - if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); - } - else - { - jobject CommandResponseState_errorStateDetailsInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, - CommandResponseState_errorStateDetails); - } - - jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct"); - return; - } - - jmethodID errorStateStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &errorStateStructStructCtor_0); - if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct constructor"); - return; - } - - CommandResponseState = - env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, - CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); - - env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); -} -CHIPOvenModeClusterChangeToModeResponseCallback::CHIPOvenModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOvenModeClusterChangeToModeResponseCallback::~CHIPOvenModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOvenModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OvenMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPLaundryWasherModeClusterChangeToModeResponseCallback::CHIPLaundryWasherModeClusterChangeToModeResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPLaundryWasherModeClusterChangeToModeResponseCallback::~CHIPLaundryWasherModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPLaundryWasherModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::LaundryWasherMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback:: -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback::~ -CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode::Commands::ChangeToModeResponse::DecodableType & - dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPRvcRunModeClusterChangeToModeResponseCallback::CHIPRvcRunModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRvcRunModeClusterChangeToModeResponseCallback::~CHIPRvcRunModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRvcRunModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::RvcRunMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPRvcCleanModeClusterChangeToModeResponseCallback::CHIPRvcCleanModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRvcCleanModeClusterChangeToModeResponseCallback::~CHIPRvcCleanModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRvcCleanModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::RvcCleanMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPDishwasherModeClusterChangeToModeResponseCallback::CHIPDishwasherModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDishwasherModeClusterChangeToModeResponseCallback::~CHIPDishwasherModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDishwasherModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DishwasherMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPOperationalStateClusterOperationalCommandResponseCallback::CHIPOperationalStateClusterOperationalCommandResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPOperationalStateClusterOperationalCommandResponseCallback::~CHIPOperationalStateClusterOperationalCommandResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Lchip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CommandResponseState; - jobject CommandResponseState_errorStateID; - std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; - std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; - jint jniCommandResponseState_errorStateID = static_cast(dataResponse.commandResponseState.errorStateID); - chip::JniReferences::GetInstance().CreateBoxedObject( - CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), - jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); - jobject CommandResponseState_errorStateLabel; - if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); - } - else - { - jobject CommandResponseState_errorStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, - CommandResponseState_errorStateLabel); - } - jobject CommandResponseState_errorStateDetails; - if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); - } - else - { - jobject CommandResponseState_errorStateDetailsInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, - CommandResponseState_errorStateDetails); - } - - jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$OperationalStateClusterErrorStateStruct"); - return; - } - - jmethodID errorStateStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &errorStateStructStructCtor_0); - if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$OperationalStateClusterErrorStateStruct constructor"); - return; - } - - CommandResponseState = - env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, - CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); - - env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); -} -CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::CHIPRvcOperationalStateClusterOperationalCommandResponseCallback( - jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::~ -CHIPRvcOperationalStateClusterOperationalCommandResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CommandResponseState; - jobject CommandResponseState_errorStateID; - std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; - std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; - jint jniCommandResponseState_errorStateID = static_cast(dataResponse.commandResponseState.errorStateID); - chip::JniReferences::GetInstance().CreateBoxedObject( - CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), - jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); - jobject CommandResponseState_errorStateLabel; - if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); - } - else - { - jobject CommandResponseState_errorStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, - CommandResponseState_errorStateLabel); - } - jobject CommandResponseState_errorStateDetails; - if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); - } - else - { - jobject CommandResponseState_errorStateDetailsInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, - CommandResponseState_errorStateDetails); - } - - jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$RvcOperationalStateClusterErrorStateStruct"); - return; - } - - jmethodID errorStateStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &errorStateStructStructCtor_0); - if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$RvcOperationalStateClusterErrorStateStruct constructor"); - return; - } - - CommandResponseState = - env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, - CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); - - env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); -} -CHIPScenesManagementClusterAddSceneResponseCallback::CHIPScenesManagementClusterAddSceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterAddSceneResponseCallback::~CHIPScenesManagementClusterAddSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterAddSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::AddSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); -} -CHIPScenesManagementClusterViewSceneResponseCallback::CHIPScenesManagementClusterViewSceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterViewSceneResponseCallback::~CHIPScenesManagementClusterViewSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterViewSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::ViewSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - jobject TransitionTime; - if (!dataResponse.transitionTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, TransitionTime); - } - else - { - jobject TransitionTimeInsideOptional; - std::string TransitionTimeInsideOptionalClassName = "java/lang/Long"; - std::string TransitionTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniTransitionTimeInsideOptional = static_cast(dataResponse.transitionTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(TransitionTimeInsideOptionalClassName.c_str(), - TransitionTimeInsideOptionalCtorSignature.c_str(), - jniTransitionTimeInsideOptional, TransitionTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(TransitionTimeInsideOptional, TransitionTime); - } - jobject SceneName; - if (!dataResponse.sceneName.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneName); - } - else - { - jobject SceneNameInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.sceneName.Value(), SceneNameInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(SceneNameInsideOptional, SceneName); - } - jobject ExtensionFieldSets; - if (!dataResponse.extensionFieldSets.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, ExtensionFieldSets); - } - else - { - jobject ExtensionFieldSetsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(ExtensionFieldSetsInsideOptional); - - auto iter_ExtensionFieldSetsInsideOptional_1 = dataResponse.extensionFieldSets.Value().begin(); - while (iter_ExtensionFieldSetsInsideOptional_1.Next()) - { - auto & entry_1 = iter_ExtensionFieldSetsInsideOptional_1.GetValue(); - jobject newElement_1; - jobject newElement_1_clusterID; - std::string newElement_1_clusterIDClassName = "java/lang/Long"; - std::string newElement_1_clusterIDCtorSignature = "(J)V"; - jlong jninewElement_1_clusterID = static_cast(entry_1.clusterID); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_clusterIDClassName.c_str(), - newElement_1_clusterIDCtorSignature.c_str(), - jninewElement_1_clusterID, newElement_1_clusterID); - jobject newElement_1_attributeValueList; - chip::JniReferences::GetInstance().CreateArrayList(newElement_1_attributeValueList); - - auto iter_newElement_1_attributeValueList_3 = entry_1.attributeValueList.begin(); - while (iter_newElement_1_attributeValueList_3.Next()) - { - auto & entry_3 = iter_newElement_1_attributeValueList_3.GetValue(); - jobject newElement_3; - jobject newElement_3_attributeID; - std::string newElement_3_attributeIDClassName = "java/lang/Long"; - std::string newElement_3_attributeIDCtorSignature = "(J)V"; - jlong jninewElement_3_attributeID = static_cast(entry_3.attributeID); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_3_attributeIDClassName.c_str(), - newElement_3_attributeIDCtorSignature.c_str(), - jninewElement_3_attributeID, newElement_3_attributeID); - jobject newElement_3_attributeValue; - std::string newElement_3_attributeValueClassName = "java/lang/Long"; - std::string newElement_3_attributeValueCtorSignature = "(J)V"; - jlong jninewElement_3_attributeValue = static_cast(entry_3.attributeValue); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_3_attributeValueClassName.c_str(), newElement_3_attributeValueCtorSignature.c_str(), - jninewElement_3_attributeValue, newElement_3_attributeValue); - - jclass attributeValuePairStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterAttributeValuePair", - attributeValuePairStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterAttributeValuePair"); - return; - } - - jmethodID attributeValuePairStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, attributeValuePairStructClass_4, "", - "(Ljava/lang/Long;Ljava/lang/Long;)V", - &attributeValuePairStructCtor_4); - if (err != CHIP_NO_ERROR || attributeValuePairStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterAttributeValuePair constructor"); - return; - } - - newElement_3 = env->NewObject(attributeValuePairStructClass_4, attributeValuePairStructCtor_4, - newElement_3_attributeID, newElement_3_attributeValue); - chip::JniReferences::GetInstance().AddToList(newElement_1_attributeValueList, newElement_3); - } - - jclass extensionFieldSetStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterExtensionFieldSet", extensionFieldSetStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterExtensionFieldSet"); - return; - } - - jmethodID extensionFieldSetStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod(env, extensionFieldSetStructClass_2, "", - "(Ljava/lang/Long;Ljava/util/ArrayList;)V", - &extensionFieldSetStructCtor_2); - if (err != CHIP_NO_ERROR || extensionFieldSetStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterExtensionFieldSet constructor"); - return; - } - - newElement_1 = env->NewObject(extensionFieldSetStructClass_2, extensionFieldSetStructCtor_2, newElement_1_clusterID, - newElement_1_attributeValueList); - chip::JniReferences::GetInstance().AddToList(ExtensionFieldSetsInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(ExtensionFieldSetsInsideOptional, ExtensionFieldSets); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID, TransitionTime, SceneName, ExtensionFieldSets); -} -CHIPScenesManagementClusterRemoveSceneResponseCallback::CHIPScenesManagementClusterRemoveSceneResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterRemoveSceneResponseCallback::~CHIPScenesManagementClusterRemoveSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterRemoveSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::RemoveSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); -} -CHIPScenesManagementClusterRemoveAllScenesResponseCallback::CHIPScenesManagementClusterRemoveAllScenesResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterRemoveAllScenesResponseCallback::~CHIPScenesManagementClusterRemoveAllScenesResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterRemoveAllScenesResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::RemoveAllScenesResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); -} -CHIPScenesManagementClusterStoreSceneResponseCallback::CHIPScenesManagementClusterStoreSceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterStoreSceneResponseCallback::~CHIPScenesManagementClusterStoreSceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterStoreSceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::StoreSceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneID; - std::string SceneIDClassName = "java/lang/Integer"; - std::string SceneIDCtorSignature = "(I)V"; - jint jniSceneID = static_cast(dataResponse.sceneID); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, - SceneID); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); -} -CHIPScenesManagementClusterGetSceneMembershipResponseCallback::CHIPScenesManagementClusterGetSceneMembershipResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterGetSceneMembershipResponseCallback::~CHIPScenesManagementClusterGetSceneMembershipResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterGetSceneMembershipResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::GetSceneMembershipResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Capacity; - if (dataResponse.capacity.IsNull()) - { - Capacity = nullptr; - } - else - { - std::string CapacityClassName = "java/lang/Integer"; - std::string CapacityCtorSignature = "(I)V"; - jint jniCapacity = static_cast(dataResponse.capacity.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CapacityClassName.c_str(), CapacityCtorSignature.c_str(), - jniCapacity, Capacity); - } - jobject GroupID; - std::string GroupIDClassName = "java/lang/Integer"; - std::string GroupIDCtorSignature = "(I)V"; - jint jniGroupID = static_cast(dataResponse.groupID); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, - GroupID); - jobject SceneList; - if (!dataResponse.sceneList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneList); - } - else - { - jobject SceneListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(SceneListInsideOptional); - - auto iter_SceneListInsideOptional_1 = dataResponse.sceneList.Value().begin(); - while (iter_SceneListInsideOptional_1.Next()) - { - auto & entry_1 = iter_SceneListInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(SceneListInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(SceneListInsideOptional, SceneList); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Capacity, GroupID, SceneList); -} -CHIPScenesManagementClusterCopySceneResponseCallback::CHIPScenesManagementClusterCopySceneResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPScenesManagementClusterCopySceneResponseCallback::~CHIPScenesManagementClusterCopySceneResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPScenesManagementClusterCopySceneResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ScenesManagement::Commands::CopySceneResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject GroupIdentifierFrom; - std::string GroupIdentifierFromClassName = "java/lang/Integer"; - std::string GroupIdentifierFromCtorSignature = "(I)V"; - jint jniGroupIdentifierFrom = static_cast(dataResponse.groupIdentifierFrom); - chip::JniReferences::GetInstance().CreateBoxedObject(GroupIdentifierFromClassName.c_str(), - GroupIdentifierFromCtorSignature.c_str(), jniGroupIdentifierFrom, - GroupIdentifierFrom); - jobject SceneIdentifierFrom; - std::string SceneIdentifierFromClassName = "java/lang/Integer"; - std::string SceneIdentifierFromCtorSignature = "(I)V"; - jint jniSceneIdentifierFrom = static_cast(dataResponse.sceneIdentifierFrom); - chip::JniReferences::GetInstance().CreateBoxedObject(SceneIdentifierFromClassName.c_str(), - SceneIdentifierFromCtorSignature.c_str(), jniSceneIdentifierFrom, - SceneIdentifierFrom); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupIdentifierFrom, SceneIdentifierFrom); -} -CHIPEnergyEvseClusterGetTargetsResponseCallback::CHIPEnergyEvseClusterGetTargetsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPEnergyEvseClusterGetTargetsResponseCallback::~CHIPEnergyEvseClusterGetTargetsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPEnergyEvseClusterGetTargetsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::EnergyEvse::Commands::GetTargetsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject ChargingTargetSchedules; - chip::JniReferences::GetInstance().CreateArrayList(ChargingTargetSchedules); - - auto iter_ChargingTargetSchedules_0 = dataResponse.chargingTargetSchedules.begin(); - while (iter_ChargingTargetSchedules_0.Next()) - { - auto & entry_0 = iter_ChargingTargetSchedules_0.GetValue(); - jobject newElement_0; - jobject newElement_0_dayOfWeekForSequence; - std::string newElement_0_dayOfWeekForSequenceClassName = "java/lang/Integer"; - std::string newElement_0_dayOfWeekForSequenceCtorSignature = "(I)V"; - jint jninewElement_0_dayOfWeekForSequence = static_cast(entry_0.dayOfWeekForSequence.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_dayOfWeekForSequenceClassName.c_str(), newElement_0_dayOfWeekForSequenceCtorSignature.c_str(), - jninewElement_0_dayOfWeekForSequence, newElement_0_dayOfWeekForSequence); - jobject newElement_0_chargingTargets; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_chargingTargets); - - auto iter_newElement_0_chargingTargets_2 = entry_0.chargingTargets.begin(); - while (iter_newElement_0_chargingTargets_2.Next()) - { - auto & entry_2 = iter_newElement_0_chargingTargets_2.GetValue(); - jobject newElement_2; - jobject newElement_2_targetTimeMinutesPastMidnight; - std::string newElement_2_targetTimeMinutesPastMidnightClassName = "java/lang/Integer"; - std::string newElement_2_targetTimeMinutesPastMidnightCtorSignature = "(I)V"; - jint jninewElement_2_targetTimeMinutesPastMidnight = static_cast(entry_2.targetTimeMinutesPastMidnight); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_targetTimeMinutesPastMidnightClassName.c_str(), - newElement_2_targetTimeMinutesPastMidnightCtorSignature.c_str(), jninewElement_2_targetTimeMinutesPastMidnight, - newElement_2_targetTimeMinutesPastMidnight); - jobject newElement_2_targetSoC; - if (!entry_2.targetSoC.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_targetSoC); - } - else - { - jobject newElement_2_targetSoCInsideOptional; - std::string newElement_2_targetSoCInsideOptionalClassName = "java/lang/Integer"; - std::string newElement_2_targetSoCInsideOptionalCtorSignature = "(I)V"; - jint jninewElement_2_targetSoCInsideOptional = static_cast(entry_2.targetSoC.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_targetSoCInsideOptionalClassName.c_str(), - newElement_2_targetSoCInsideOptionalCtorSignature.c_str(), jninewElement_2_targetSoCInsideOptional, - newElement_2_targetSoCInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_2_targetSoCInsideOptional, newElement_2_targetSoC); - } - jobject newElement_2_addedEnergy; - if (!entry_2.addedEnergy.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_addedEnergy); - } - else - { - jobject newElement_2_addedEnergyInsideOptional; - std::string newElement_2_addedEnergyInsideOptionalClassName = "java/lang/Long"; - std::string newElement_2_addedEnergyInsideOptionalCtorSignature = "(J)V"; - jlong jninewElement_2_addedEnergyInsideOptional = static_cast(entry_2.addedEnergy.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_addedEnergyInsideOptionalClassName.c_str(), - newElement_2_addedEnergyInsideOptionalCtorSignature.c_str(), jninewElement_2_addedEnergyInsideOptional, - newElement_2_addedEnergyInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_2_addedEnergyInsideOptional, newElement_2_addedEnergy); - } - - jclass chargingTargetStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$EnergyEvseClusterChargingTargetStruct", chargingTargetStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$EnergyEvseClusterChargingTargetStruct"); - return; - } - - jmethodID chargingTargetStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod(env, chargingTargetStructStructClass_3, "", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", - &chargingTargetStructStructCtor_3); - if (err != CHIP_NO_ERROR || chargingTargetStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$EnergyEvseClusterChargingTargetStruct constructor"); - return; - } - - newElement_2 = - env->NewObject(chargingTargetStructStructClass_3, chargingTargetStructStructCtor_3, - newElement_2_targetTimeMinutesPastMidnight, newElement_2_targetSoC, newElement_2_addedEnergy); - chip::JniReferences::GetInstance().AddToList(newElement_0_chargingTargets, newElement_2); - } - - jclass chargingTargetScheduleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct", - chargingTargetScheduleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct"); - return; - } - - jmethodID chargingTargetScheduleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, chargingTargetScheduleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &chargingTargetScheduleStructStructCtor_1); - if (err != CHIP_NO_ERROR || chargingTargetScheduleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct constructor"); - return; - } - - newElement_0 = env->NewObject(chargingTargetScheduleStructStructClass_1, chargingTargetScheduleStructStructCtor_1, - newElement_0_dayOfWeekForSequence, newElement_0_chargingTargets); - chip::JniReferences::GetInstance().AddToList(ChargingTargetSchedules, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, ChargingTargetSchedules); -} -CHIPEnergyEvseModeClusterChangeToModeResponseCallback::CHIPEnergyEvseModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPEnergyEvseModeClusterChangeToModeResponseCallback::~CHIPEnergyEvseModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPEnergyEvseModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::EnergyEvseMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback:: -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback::~ -CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDeviceEnergyManagementModeClusterChangeToModeResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::DeviceEnergyManagementMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject StatusText; - if (!dataResponse.statusText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); - } - else - { - jobject StatusTextInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); -} -CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::CHIPDoorLockClusterGetWeekDayScheduleResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::~CHIPDoorLockClusterGetWeekDayScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject WeekDayIndex; - std::string WeekDayIndexClassName = "java/lang/Integer"; - std::string WeekDayIndexCtorSignature = "(I)V"; - jint jniWeekDayIndex = static_cast(dataResponse.weekDayIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(WeekDayIndexClassName.c_str(), WeekDayIndexCtorSignature.c_str(), - jniWeekDayIndex, WeekDayIndex); - jobject UserIndex; - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject DaysMask; - if (!dataResponse.daysMask.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, DaysMask); - } - else - { - jobject DaysMaskInsideOptional; - std::string DaysMaskInsideOptionalClassName = "java/lang/Integer"; - std::string DaysMaskInsideOptionalCtorSignature = "(I)V"; - jint jniDaysMaskInsideOptional = static_cast(dataResponse.daysMask.Value().Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(DaysMaskInsideOptionalClassName.c_str(), - DaysMaskInsideOptionalCtorSignature.c_str(), - jniDaysMaskInsideOptional, DaysMaskInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(DaysMaskInsideOptional, DaysMask); - } - jobject StartHour; - if (!dataResponse.startHour.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StartHour); - } - else - { - jobject StartHourInsideOptional; - std::string StartHourInsideOptionalClassName = "java/lang/Integer"; - std::string StartHourInsideOptionalCtorSignature = "(I)V"; - jint jniStartHourInsideOptional = static_cast(dataResponse.startHour.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(StartHourInsideOptionalClassName.c_str(), - StartHourInsideOptionalCtorSignature.c_str(), - jniStartHourInsideOptional, StartHourInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(StartHourInsideOptional, StartHour); - } - jobject StartMinute; - if (!dataResponse.startMinute.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, StartMinute); - } - else - { - jobject StartMinuteInsideOptional; - std::string StartMinuteInsideOptionalClassName = "java/lang/Integer"; - std::string StartMinuteInsideOptionalCtorSignature = "(I)V"; - jint jniStartMinuteInsideOptional = static_cast(dataResponse.startMinute.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(StartMinuteInsideOptionalClassName.c_str(), - StartMinuteInsideOptionalCtorSignature.c_str(), - jniStartMinuteInsideOptional, StartMinuteInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(StartMinuteInsideOptional, StartMinute); - } - jobject EndHour; - if (!dataResponse.endHour.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, EndHour); - } - else - { - jobject EndHourInsideOptional; - std::string EndHourInsideOptionalClassName = "java/lang/Integer"; - std::string EndHourInsideOptionalCtorSignature = "(I)V"; - jint jniEndHourInsideOptional = static_cast(dataResponse.endHour.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(EndHourInsideOptionalClassName.c_str(), - EndHourInsideOptionalCtorSignature.c_str(), - jniEndHourInsideOptional, EndHourInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(EndHourInsideOptional, EndHour); - } - jobject EndMinute; - if (!dataResponse.endMinute.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, EndMinute); - } - else - { - jobject EndMinuteInsideOptional; - std::string EndMinuteInsideOptionalClassName = "java/lang/Integer"; - std::string EndMinuteInsideOptionalCtorSignature = "(I)V"; - jint jniEndMinuteInsideOptional = static_cast(dataResponse.endMinute.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(EndMinuteInsideOptionalClassName.c_str(), - EndMinuteInsideOptionalCtorSignature.c_str(), - jniEndMinuteInsideOptional, EndMinuteInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(EndMinuteInsideOptional, EndMinute); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, WeekDayIndex, UserIndex, Status, DaysMask, StartHour, StartMinute, EndHour, - EndMinute); -} -CHIPDoorLockClusterGetYearDayScheduleResponseCallback::CHIPDoorLockClusterGetYearDayScheduleResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetYearDayScheduleResponseCallback::~CHIPDoorLockClusterGetYearDayScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetYearDayScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject YearDayIndex; - std::string YearDayIndexClassName = "java/lang/Integer"; - std::string YearDayIndexCtorSignature = "(I)V"; - jint jniYearDayIndex = static_cast(dataResponse.yearDayIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(YearDayIndexClassName.c_str(), YearDayIndexCtorSignature.c_str(), - jniYearDayIndex, YearDayIndex); - jobject UserIndex; - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject LocalStartTime; - if (!dataResponse.localStartTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalStartTime); - } - else - { - jobject LocalStartTimeInsideOptional; - std::string LocalStartTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalStartTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalStartTimeInsideOptional = static_cast(dataResponse.localStartTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalStartTimeInsideOptionalClassName.c_str(), - LocalStartTimeInsideOptionalCtorSignature.c_str(), - jniLocalStartTimeInsideOptional, LocalStartTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalStartTimeInsideOptional, LocalStartTime); - } - jobject LocalEndTime; - if (!dataResponse.localEndTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalEndTime); - } - else - { - jobject LocalEndTimeInsideOptional; - std::string LocalEndTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalEndTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalEndTimeInsideOptional = static_cast(dataResponse.localEndTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalEndTimeInsideOptionalClassName.c_str(), - LocalEndTimeInsideOptionalCtorSignature.c_str(), - jniLocalEndTimeInsideOptional, LocalEndTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalEndTimeInsideOptional, LocalEndTime); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, YearDayIndex, UserIndex, Status, LocalStartTime, LocalEndTime); -} -CHIPDoorLockClusterGetHolidayScheduleResponseCallback::CHIPDoorLockClusterGetHolidayScheduleResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetHolidayScheduleResponseCallback::~CHIPDoorLockClusterGetHolidayScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetHolidayScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject HolidayIndex; - std::string HolidayIndexClassName = "java/lang/Integer"; - std::string HolidayIndexCtorSignature = "(I)V"; - jint jniHolidayIndex = static_cast(dataResponse.holidayIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(HolidayIndexClassName.c_str(), HolidayIndexCtorSignature.c_str(), - jniHolidayIndex, HolidayIndex); - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject LocalStartTime; - if (!dataResponse.localStartTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalStartTime); - } - else - { - jobject LocalStartTimeInsideOptional; - std::string LocalStartTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalStartTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalStartTimeInsideOptional = static_cast(dataResponse.localStartTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalStartTimeInsideOptionalClassName.c_str(), - LocalStartTimeInsideOptionalCtorSignature.c_str(), - jniLocalStartTimeInsideOptional, LocalStartTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalStartTimeInsideOptional, LocalStartTime); - } - jobject LocalEndTime; - if (!dataResponse.localEndTime.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalEndTime); - } - else - { - jobject LocalEndTimeInsideOptional; - std::string LocalEndTimeInsideOptionalClassName = "java/lang/Long"; - std::string LocalEndTimeInsideOptionalCtorSignature = "(J)V"; - jlong jniLocalEndTimeInsideOptional = static_cast(dataResponse.localEndTime.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LocalEndTimeInsideOptionalClassName.c_str(), - LocalEndTimeInsideOptionalCtorSignature.c_str(), - jniLocalEndTimeInsideOptional, LocalEndTimeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(LocalEndTimeInsideOptional, LocalEndTime); - } - jobject OperatingMode; - if (!dataResponse.operatingMode.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OperatingMode); - } - else - { - jobject OperatingModeInsideOptional; - std::string OperatingModeInsideOptionalClassName = "java/lang/Integer"; - std::string OperatingModeInsideOptionalCtorSignature = "(I)V"; - jint jniOperatingModeInsideOptional = static_cast(dataResponse.operatingMode.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(OperatingModeInsideOptionalClassName.c_str(), - OperatingModeInsideOptionalCtorSignature.c_str(), - jniOperatingModeInsideOptional, OperatingModeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(OperatingModeInsideOptional, OperatingMode); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, HolidayIndex, Status, LocalStartTime, LocalEndTime, OperatingMode); -} -CHIPDoorLockClusterGetUserResponseCallback::CHIPDoorLockClusterGetUserResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetUserResponseCallback::~CHIPDoorLockClusterGetUserResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetUserResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/" - "ArrayList;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject UserIndex; - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - jobject UserName; - if (dataResponse.userName.IsNull()) - { - UserName = nullptr; - } - else - { - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.userName.Value(), UserName)); - } - jobject UserUniqueID; - if (dataResponse.userUniqueID.IsNull()) - { - UserUniqueID = nullptr; - } - else - { - std::string UserUniqueIDClassName = "java/lang/Long"; - std::string UserUniqueIDCtorSignature = "(J)V"; - jlong jniUserUniqueID = static_cast(dataResponse.userUniqueID.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - UserUniqueIDClassName.c_str(), UserUniqueIDCtorSignature.c_str(), jniUserUniqueID, UserUniqueID); - } - jobject UserStatus; - if (dataResponse.userStatus.IsNull()) - { - UserStatus = nullptr; - } - else - { - std::string UserStatusClassName = "java/lang/Integer"; - std::string UserStatusCtorSignature = "(I)V"; - jint jniUserStatus = static_cast(dataResponse.userStatus.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserStatusClassName.c_str(), UserStatusCtorSignature.c_str(), - jniUserStatus, UserStatus); - } - jobject UserType; - if (dataResponse.userType.IsNull()) - { - UserType = nullptr; - } - else - { - std::string UserTypeClassName = "java/lang/Integer"; - std::string UserTypeCtorSignature = "(I)V"; - jint jniUserType = static_cast(dataResponse.userType.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserTypeClassName.c_str(), UserTypeCtorSignature.c_str(), - jniUserType, UserType); - } - jobject CredentialRule; - if (dataResponse.credentialRule.IsNull()) - { - CredentialRule = nullptr; - } - else - { - std::string CredentialRuleClassName = "java/lang/Integer"; - std::string CredentialRuleCtorSignature = "(I)V"; - jint jniCredentialRule = static_cast(dataResponse.credentialRule.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - CredentialRuleClassName.c_str(), CredentialRuleCtorSignature.c_str(), jniCredentialRule, CredentialRule); - } - jobject Credentials; - if (dataResponse.credentials.IsNull()) - { - Credentials = nullptr; - } - else - { - chip::JniReferences::GetInstance().CreateArrayList(Credentials); - - auto iter_Credentials_1 = dataResponse.credentials.Value().begin(); - while (iter_Credentials_1.Next()) - { - auto & entry_1 = iter_Credentials_1.GetValue(); - jobject newElement_1; - jobject newElement_1_credentialType; - std::string newElement_1_credentialTypeClassName = "java/lang/Integer"; - std::string newElement_1_credentialTypeCtorSignature = "(I)V"; - jint jninewElement_1_credentialType = static_cast(entry_1.credentialType); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_credentialTypeClassName.c_str(), - newElement_1_credentialTypeCtorSignature.c_str(), - jninewElement_1_credentialType, newElement_1_credentialType); - jobject newElement_1_credentialIndex; - std::string newElement_1_credentialIndexClassName = "java/lang/Integer"; - std::string newElement_1_credentialIndexCtorSignature = "(I)V"; - jint jninewElement_1_credentialIndex = static_cast(entry_1.credentialIndex); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1_credentialIndexClassName.c_str(), newElement_1_credentialIndexCtorSignature.c_str(), - jninewElement_1_credentialIndex, newElement_1_credentialIndex); - - jclass credentialStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$DoorLockClusterCredentialStruct", credentialStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$DoorLockClusterCredentialStruct"); - return; - } - - jmethodID credentialStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod(env, credentialStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &credentialStructStructCtor_2); - if (err != CHIP_NO_ERROR || credentialStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$DoorLockClusterCredentialStruct constructor"); - return; - } - - newElement_1 = env->NewObject(credentialStructStructClass_2, credentialStructStructCtor_2, newElement_1_credentialType, - newElement_1_credentialIndex); - chip::JniReferences::GetInstance().AddToList(Credentials, newElement_1); - } - } - jobject CreatorFabricIndex; - if (dataResponse.creatorFabricIndex.IsNull()) - { - CreatorFabricIndex = nullptr; - } - else - { - std::string CreatorFabricIndexClassName = "java/lang/Integer"; - std::string CreatorFabricIndexCtorSignature = "(I)V"; - jint jniCreatorFabricIndex = static_cast(dataResponse.creatorFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CreatorFabricIndexClassName.c_str(), - CreatorFabricIndexCtorSignature.c_str(), jniCreatorFabricIndex, - CreatorFabricIndex); - } - jobject LastModifiedFabricIndex; - if (dataResponse.lastModifiedFabricIndex.IsNull()) - { - LastModifiedFabricIndex = nullptr; - } - else - { - std::string LastModifiedFabricIndexClassName = "java/lang/Integer"; - std::string LastModifiedFabricIndexCtorSignature = "(I)V"; - jint jniLastModifiedFabricIndex = static_cast(dataResponse.lastModifiedFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LastModifiedFabricIndexClassName.c_str(), - LastModifiedFabricIndexCtorSignature.c_str(), - jniLastModifiedFabricIndex, LastModifiedFabricIndex); - } - jobject NextUserIndex; - if (dataResponse.nextUserIndex.IsNull()) - { - NextUserIndex = nullptr; - } - else - { - std::string NextUserIndexClassName = "java/lang/Integer"; - std::string NextUserIndexCtorSignature = "(I)V"; - jint jniNextUserIndex = static_cast(dataResponse.nextUserIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NextUserIndexClassName.c_str(), NextUserIndexCtorSignature.c_str(), jniNextUserIndex, NextUserIndex); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, UserIndex, UserName, UserUniqueID, UserStatus, UserType, CredentialRule, - Credentials, CreatorFabricIndex, LastModifiedFabricIndex, NextUserIndex); -} -CHIPDoorLockClusterSetCredentialResponseCallback::CHIPDoorLockClusterSetCredentialResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterSetCredentialResponseCallback::~CHIPDoorLockClusterSetCredentialResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterSetCredentialResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject UserIndex; - if (dataResponse.userIndex.IsNull()) - { - UserIndex = nullptr; - } - else - { - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - } - jobject NextCredentialIndex; - if (dataResponse.nextCredentialIndex.IsNull()) - { - NextCredentialIndex = nullptr; - } - else - { - std::string NextCredentialIndexClassName = "java/lang/Integer"; - std::string NextCredentialIndexCtorSignature = "(I)V"; - jint jniNextCredentialIndex = static_cast(dataResponse.nextCredentialIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(NextCredentialIndexClassName.c_str(), - NextCredentialIndexCtorSignature.c_str(), jniNextCredentialIndex, - NextCredentialIndex); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, UserIndex, NextCredentialIndex); -} -CHIPDoorLockClusterGetCredentialStatusResponseCallback::CHIPDoorLockClusterGetCredentialStatusResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPDoorLockClusterGetCredentialStatusResponseCallback::~CHIPDoorLockClusterGetCredentialStatusResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPDoorLockClusterGetCredentialStatusResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Boolean;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject CredentialExists; - std::string CredentialExistsClassName = "java/lang/Boolean"; - std::string CredentialExistsCtorSignature = "(Z)V"; - jboolean jniCredentialExists = static_cast(dataResponse.credentialExists); - chip::JniReferences::GetInstance().CreateBoxedObject( - CredentialExistsClassName.c_str(), CredentialExistsCtorSignature.c_str(), jniCredentialExists, CredentialExists); - jobject UserIndex; - if (dataResponse.userIndex.IsNull()) - { - UserIndex = nullptr; - } - else - { - std::string UserIndexClassName = "java/lang/Integer"; - std::string UserIndexCtorSignature = "(I)V"; - jint jniUserIndex = static_cast(dataResponse.userIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), - jniUserIndex, UserIndex); - } - jobject CreatorFabricIndex; - if (dataResponse.creatorFabricIndex.IsNull()) - { - CreatorFabricIndex = nullptr; - } - else - { - std::string CreatorFabricIndexClassName = "java/lang/Integer"; - std::string CreatorFabricIndexCtorSignature = "(I)V"; - jint jniCreatorFabricIndex = static_cast(dataResponse.creatorFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(CreatorFabricIndexClassName.c_str(), - CreatorFabricIndexCtorSignature.c_str(), jniCreatorFabricIndex, - CreatorFabricIndex); - } - jobject LastModifiedFabricIndex; - if (dataResponse.lastModifiedFabricIndex.IsNull()) - { - LastModifiedFabricIndex = nullptr; - } - else - { - std::string LastModifiedFabricIndexClassName = "java/lang/Integer"; - std::string LastModifiedFabricIndexCtorSignature = "(I)V"; - jint jniLastModifiedFabricIndex = static_cast(dataResponse.lastModifiedFabricIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(LastModifiedFabricIndexClassName.c_str(), - LastModifiedFabricIndexCtorSignature.c_str(), - jniLastModifiedFabricIndex, LastModifiedFabricIndex); - } - jobject NextCredentialIndex; - if (dataResponse.nextCredentialIndex.IsNull()) - { - NextCredentialIndex = nullptr; - } - else - { - std::string NextCredentialIndexClassName = "java/lang/Integer"; - std::string NextCredentialIndexCtorSignature = "(I)V"; - jint jniNextCredentialIndex = static_cast(dataResponse.nextCredentialIndex.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(NextCredentialIndexClassName.c_str(), - NextCredentialIndexCtorSignature.c_str(), jniNextCredentialIndex, - NextCredentialIndex); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, CredentialExists, UserIndex, CreatorFabricIndex, LastModifiedFabricIndex, - NextCredentialIndex); -} -CHIPThermostatClusterGetWeeklyScheduleResponseCallback::CHIPThermostatClusterGetWeeklyScheduleResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPThermostatClusterGetWeeklyScheduleResponseCallback::~CHIPThermostatClusterGetWeeklyScheduleResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPThermostatClusterGetWeeklyScheduleResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NumberOfTransitionsForSequence; - std::string NumberOfTransitionsForSequenceClassName = "java/lang/Integer"; - std::string NumberOfTransitionsForSequenceCtorSignature = "(I)V"; - jint jniNumberOfTransitionsForSequence = static_cast(dataResponse.numberOfTransitionsForSequence); - chip::JniReferences::GetInstance().CreateBoxedObject(NumberOfTransitionsForSequenceClassName.c_str(), - NumberOfTransitionsForSequenceCtorSignature.c_str(), - jniNumberOfTransitionsForSequence, NumberOfTransitionsForSequence); - jobject DayOfWeekForSequence; - std::string DayOfWeekForSequenceClassName = "java/lang/Integer"; - std::string DayOfWeekForSequenceCtorSignature = "(I)V"; - jint jniDayOfWeekForSequence = static_cast(dataResponse.dayOfWeekForSequence.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(DayOfWeekForSequenceClassName.c_str(), - DayOfWeekForSequenceCtorSignature.c_str(), jniDayOfWeekForSequence, - DayOfWeekForSequence); - jobject ModeForSequence; - std::string ModeForSequenceClassName = "java/lang/Integer"; - std::string ModeForSequenceCtorSignature = "(I)V"; - jint jniModeForSequence = static_cast(dataResponse.modeForSequence.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - ModeForSequenceClassName.c_str(), ModeForSequenceCtorSignature.c_str(), jniModeForSequence, ModeForSequence); - jobject Transitions; - chip::JniReferences::GetInstance().CreateArrayList(Transitions); - - auto iter_Transitions_0 = dataResponse.transitions.begin(); - while (iter_Transitions_0.Next()) - { - auto & entry_0 = iter_Transitions_0.GetValue(); - jobject newElement_0; - jobject newElement_0_transitionTime; - std::string newElement_0_transitionTimeClassName = "java/lang/Integer"; - std::string newElement_0_transitionTimeCtorSignature = "(I)V"; - jint jninewElement_0_transitionTime = static_cast(entry_0.transitionTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_transitionTimeClassName.c_str(), - newElement_0_transitionTimeCtorSignature.c_str(), - jninewElement_0_transitionTime, newElement_0_transitionTime); - jobject newElement_0_heatSetpoint; - if (entry_0.heatSetpoint.IsNull()) - { - newElement_0_heatSetpoint = nullptr; - } - else - { - std::string newElement_0_heatSetpointClassName = "java/lang/Integer"; - std::string newElement_0_heatSetpointCtorSignature = "(I)V"; - jint jninewElement_0_heatSetpoint = static_cast(entry_0.heatSetpoint.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_heatSetpointClassName.c_str(), - newElement_0_heatSetpointCtorSignature.c_str(), - jninewElement_0_heatSetpoint, newElement_0_heatSetpoint); - } - jobject newElement_0_coolSetpoint; - if (entry_0.coolSetpoint.IsNull()) - { - newElement_0_coolSetpoint = nullptr; - } - else - { - std::string newElement_0_coolSetpointClassName = "java/lang/Integer"; - std::string newElement_0_coolSetpointCtorSignature = "(I)V"; - jint jninewElement_0_coolSetpoint = static_cast(entry_0.coolSetpoint.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_coolSetpointClassName.c_str(), - newElement_0_coolSetpointCtorSignature.c_str(), - jninewElement_0_coolSetpoint, newElement_0_coolSetpoint); - } - - jclass weeklyScheduleTransitionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct", - weeklyScheduleTransitionStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct"); - return; - } - - jmethodID weeklyScheduleTransitionStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, weeklyScheduleTransitionStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", - &weeklyScheduleTransitionStructStructCtor_1); - if (err != CHIP_NO_ERROR || weeklyScheduleTransitionStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct constructor"); - return; - } - - newElement_0 = env->NewObject(weeklyScheduleTransitionStructStructClass_1, weeklyScheduleTransitionStructStructCtor_1, - newElement_0_transitionTime, newElement_0_heatSetpoint, newElement_0_coolSetpoint); - chip::JniReferences::GetInstance().AddToList(Transitions, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NumberOfTransitionsForSequence, DayOfWeekForSequence, ModeForSequence, - Transitions); -} -CHIPChannelClusterChangeChannelResponseCallback::CHIPChannelClusterChangeChannelResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPChannelClusterChangeChannelResponseCallback::~CHIPChannelClusterChangeChannelResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPChannelClusterChangeChannelResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPChannelClusterProgramGuideResponseCallback::CHIPChannelClusterProgramGuideResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPChannelClusterProgramGuideResponseCallback::~CHIPChannelClusterProgramGuideResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPChannelClusterProgramGuideResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::Channel::Commands::ProgramGuideResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Lchip/devicecontroller/ChipStructs$ChannelClusterChannelPagingStruct;Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Paging; - jobject Paging_previousToken; - if (!dataResponse.paging.previousToken.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousToken); - } - else - { - jobject Paging_previousTokenInsideOptional; - if (dataResponse.paging.previousToken.Value().IsNull()) - { - Paging_previousTokenInsideOptional = nullptr; - } - else - { - jobject Paging_previousTokenInsideOptional_limit; - if (!dataResponse.paging.previousToken.Value().Value().limit.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_limit); - } - else - { - jobject Paging_previousTokenInsideOptional_limitInsideOptional; - std::string Paging_previousTokenInsideOptional_limitInsideOptionalClassName = "java/lang/Integer"; - std::string Paging_previousTokenInsideOptional_limitInsideOptionalCtorSignature = "(I)V"; - jint jniPaging_previousTokenInsideOptional_limitInsideOptional = - static_cast(dataResponse.paging.previousToken.Value().Value().limit.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - Paging_previousTokenInsideOptional_limitInsideOptionalClassName.c_str(), - Paging_previousTokenInsideOptional_limitInsideOptionalCtorSignature.c_str(), - jniPaging_previousTokenInsideOptional_limitInsideOptional, - Paging_previousTokenInsideOptional_limitInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_limitInsideOptional, - Paging_previousTokenInsideOptional_limit); - } - jobject Paging_previousTokenInsideOptional_after; - if (!dataResponse.paging.previousToken.Value().Value().after.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_after); - } - else - { - jobject Paging_previousTokenInsideOptional_afterInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.paging.previousToken.Value().Value().after.Value(), - Paging_previousTokenInsideOptional_afterInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_afterInsideOptional, - Paging_previousTokenInsideOptional_after); - } - jobject Paging_previousTokenInsideOptional_before; - if (!dataResponse.paging.previousToken.Value().Value().before.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_before); - } - else - { - jobject Paging_previousTokenInsideOptional_beforeInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - dataResponse.paging.previousToken.Value().Value().before.Value(), - Paging_previousTokenInsideOptional_beforeInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_beforeInsideOptional, - Paging_previousTokenInsideOptional_before); - } - - jclass pageTokenStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterPageTokenStruct", pageTokenStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterPageTokenStruct"); - return; - } - - jmethodID pageTokenStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod(env, pageTokenStructStructClass_3, "", - "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &pageTokenStructStructCtor_3); - if (err != CHIP_NO_ERROR || pageTokenStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterPageTokenStruct constructor"); - return; - } - - Paging_previousTokenInsideOptional = - env->NewObject(pageTokenStructStructClass_3, pageTokenStructStructCtor_3, Paging_previousTokenInsideOptional_limit, - Paging_previousTokenInsideOptional_after, Paging_previousTokenInsideOptional_before); - } - chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional, Paging_previousToken); - } - jobject Paging_nextToken; - if (!dataResponse.paging.nextToken.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextToken); - } - else - { - jobject Paging_nextTokenInsideOptional; - if (dataResponse.paging.nextToken.Value().IsNull()) - { - Paging_nextTokenInsideOptional = nullptr; - } - else - { - jobject Paging_nextTokenInsideOptional_limit; - if (!dataResponse.paging.nextToken.Value().Value().limit.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_limit); - } - else - { - jobject Paging_nextTokenInsideOptional_limitInsideOptional; - std::string Paging_nextTokenInsideOptional_limitInsideOptionalClassName = "java/lang/Integer"; - std::string Paging_nextTokenInsideOptional_limitInsideOptionalCtorSignature = "(I)V"; - jint jniPaging_nextTokenInsideOptional_limitInsideOptional = - static_cast(dataResponse.paging.nextToken.Value().Value().limit.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - Paging_nextTokenInsideOptional_limitInsideOptionalClassName.c_str(), - Paging_nextTokenInsideOptional_limitInsideOptionalCtorSignature.c_str(), - jniPaging_nextTokenInsideOptional_limitInsideOptional, Paging_nextTokenInsideOptional_limitInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_limitInsideOptional, - Paging_nextTokenInsideOptional_limit); - } - jobject Paging_nextTokenInsideOptional_after; - if (!dataResponse.paging.nextToken.Value().Value().after.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_after); - } - else - { - jobject Paging_nextTokenInsideOptional_afterInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.paging.nextToken.Value().Value().after.Value(), - Paging_nextTokenInsideOptional_afterInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_afterInsideOptional, - Paging_nextTokenInsideOptional_after); - } - jobject Paging_nextTokenInsideOptional_before; - if (!dataResponse.paging.nextToken.Value().Value().before.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_before); - } - else - { - jobject Paging_nextTokenInsideOptional_beforeInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.paging.nextToken.Value().Value().before.Value(), - Paging_nextTokenInsideOptional_beforeInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_beforeInsideOptional, - Paging_nextTokenInsideOptional_before); - } - - jclass pageTokenStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterPageTokenStruct", pageTokenStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterPageTokenStruct"); - return; - } - - jmethodID pageTokenStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod(env, pageTokenStructStructClass_3, "", - "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &pageTokenStructStructCtor_3); - if (err != CHIP_NO_ERROR || pageTokenStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterPageTokenStruct constructor"); - return; - } - - Paging_nextTokenInsideOptional = - env->NewObject(pageTokenStructStructClass_3, pageTokenStructStructCtor_3, Paging_nextTokenInsideOptional_limit, - Paging_nextTokenInsideOptional_after, Paging_nextTokenInsideOptional_before); - } - chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional, Paging_nextToken); - } - - jclass channelPagingStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelPagingStruct", - channelPagingStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterChannelPagingStruct"); - return; - } - - jmethodID channelPagingStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, channelPagingStructStructClass_0, "", - "(Ljava/util/Optional;Ljava/util/Optional;)V", - &channelPagingStructStructCtor_0); - if (err != CHIP_NO_ERROR || channelPagingStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterChannelPagingStruct constructor"); - return; - } - - Paging = - env->NewObject(channelPagingStructStructClass_0, channelPagingStructStructCtor_0, Paging_previousToken, Paging_nextToken); - jobject ProgramList; - chip::JniReferences::GetInstance().CreateArrayList(ProgramList); - - auto iter_ProgramList_0 = dataResponse.programList.begin(); - while (iter_ProgramList_0.Next()) - { - auto & entry_0 = iter_ProgramList_0.GetValue(); - jobject newElement_0; - jobject newElement_0_identifier; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.identifier, newElement_0_identifier)); - jobject newElement_0_channel; - jobject newElement_0_channel_majorNumber; - std::string newElement_0_channel_majorNumberClassName = "java/lang/Integer"; - std::string newElement_0_channel_majorNumberCtorSignature = "(I)V"; - jint jninewElement_0_channel_majorNumber = static_cast(entry_0.channel.majorNumber); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_channel_majorNumberClassName.c_str(), newElement_0_channel_majorNumberCtorSignature.c_str(), - jninewElement_0_channel_majorNumber, newElement_0_channel_majorNumber); - jobject newElement_0_channel_minorNumber; - std::string newElement_0_channel_minorNumberClassName = "java/lang/Integer"; - std::string newElement_0_channel_minorNumberCtorSignature = "(I)V"; - jint jninewElement_0_channel_minorNumber = static_cast(entry_0.channel.minorNumber); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_channel_minorNumberClassName.c_str(), newElement_0_channel_minorNumberCtorSignature.c_str(), - jninewElement_0_channel_minorNumber, newElement_0_channel_minorNumber); - jobject newElement_0_channel_name; - if (!entry_0.channel.name.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_name); - } - else - { - jobject newElement_0_channel_nameInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.name.Value(), - newElement_0_channel_nameInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_nameInsideOptional, newElement_0_channel_name); - } - jobject newElement_0_channel_callSign; - if (!entry_0.channel.callSign.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_callSign); - } - else - { - jobject newElement_0_channel_callSignInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.callSign.Value(), - newElement_0_channel_callSignInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_callSignInsideOptional, - newElement_0_channel_callSign); - } - jobject newElement_0_channel_affiliateCallSign; - if (!entry_0.channel.affiliateCallSign.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_affiliateCallSign); - } - else - { - jobject newElement_0_channel_affiliateCallSignInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - entry_0.channel.affiliateCallSign.Value(), newElement_0_channel_affiliateCallSignInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_affiliateCallSignInsideOptional, - newElement_0_channel_affiliateCallSign); - } - jobject newElement_0_channel_identifier; - if (!entry_0.channel.identifier.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_identifier); - } - else - { - jobject newElement_0_channel_identifierInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.identifier.Value(), - newElement_0_channel_identifierInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_identifierInsideOptional, - newElement_0_channel_identifier); - } - jobject newElement_0_channel_type; - if (!entry_0.channel.type.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_type); - } - else - { - jobject newElement_0_channel_typeInsideOptional; - std::string newElement_0_channel_typeInsideOptionalClassName = "java/lang/Integer"; - std::string newElement_0_channel_typeInsideOptionalCtorSignature = "(I)V"; - jint jninewElement_0_channel_typeInsideOptional = static_cast(entry_0.channel.type.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_channel_typeInsideOptionalClassName.c_str(), - newElement_0_channel_typeInsideOptionalCtorSignature.c_str(), - jninewElement_0_channel_typeInsideOptional, - newElement_0_channel_typeInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_typeInsideOptional, newElement_0_channel_type); - } - - jclass channelInfoStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct", channelInfoStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterChannelInfoStruct"); - return; - } - - jmethodID channelInfoStructStructCtor_2; - err = - chip::JniReferences::GetInstance().FindMethod(env, channelInfoStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &channelInfoStructStructCtor_2); - if (err != CHIP_NO_ERROR || channelInfoStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterChannelInfoStruct constructor"); - return; - } - - newElement_0_channel = - env->NewObject(channelInfoStructStructClass_2, channelInfoStructStructCtor_2, newElement_0_channel_majorNumber, - newElement_0_channel_minorNumber, newElement_0_channel_name, newElement_0_channel_callSign, - newElement_0_channel_affiliateCallSign, newElement_0_channel_identifier, newElement_0_channel_type); - jobject newElement_0_startTime; - std::string newElement_0_startTimeClassName = "java/lang/Long"; - std::string newElement_0_startTimeCtorSignature = "(J)V"; - jlong jninewElement_0_startTime = static_cast(entry_0.startTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_startTimeClassName.c_str(), - newElement_0_startTimeCtorSignature.c_str(), - jninewElement_0_startTime, newElement_0_startTime); - jobject newElement_0_endTime; - std::string newElement_0_endTimeClassName = "java/lang/Long"; - std::string newElement_0_endTimeCtorSignature = "(J)V"; - jlong jninewElement_0_endTime = static_cast(entry_0.endTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_endTimeClassName.c_str(), - newElement_0_endTimeCtorSignature.c_str(), - jninewElement_0_endTime, newElement_0_endTime); - jobject newElement_0_title; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.title, newElement_0_title)); - jobject newElement_0_subtitle; - if (!entry_0.subtitle.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_subtitle); - } - else - { - jobject newElement_0_subtitleInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(entry_0.subtitle.Value(), newElement_0_subtitleInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_subtitleInsideOptional, newElement_0_subtitle); - } - jobject newElement_0_description; - if (!entry_0.description.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_description); - } - else - { - jobject newElement_0_descriptionInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.description.Value(), - newElement_0_descriptionInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_descriptionInsideOptional, newElement_0_description); - } - jobject newElement_0_audioLanguages; - if (!entry_0.audioLanguages.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_audioLanguages); - } - else - { - jobject newElement_0_audioLanguagesInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_audioLanguagesInsideOptional); - - auto iter_newElement_0_audioLanguagesInsideOptional_3 = entry_0.audioLanguages.Value().begin(); - while (iter_newElement_0_audioLanguagesInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_audioLanguagesInsideOptional_3.GetValue(); - jobject newElement_3; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3, newElement_3)); - chip::JniReferences::GetInstance().AddToList(newElement_0_audioLanguagesInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_audioLanguagesInsideOptional, - newElement_0_audioLanguages); - } - jobject newElement_0_ratings; - if (!entry_0.ratings.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_ratings); - } - else - { - jobject newElement_0_ratingsInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_ratingsInsideOptional); - - auto iter_newElement_0_ratingsInsideOptional_3 = entry_0.ratings.Value().begin(); - while (iter_newElement_0_ratingsInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_ratingsInsideOptional_3.GetValue(); - jobject newElement_3; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3, newElement_3)); - chip::JniReferences::GetInstance().AddToList(newElement_0_ratingsInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_ratingsInsideOptional, newElement_0_ratings); - } - jobject newElement_0_thumbnailUrl; - if (!entry_0.thumbnailUrl.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_thumbnailUrl); - } - else - { - jobject newElement_0_thumbnailUrlInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.thumbnailUrl.Value(), - newElement_0_thumbnailUrlInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_thumbnailUrlInsideOptional, newElement_0_thumbnailUrl); - } - jobject newElement_0_posterArtUrl; - if (!entry_0.posterArtUrl.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_posterArtUrl); - } - else - { - jobject newElement_0_posterArtUrlInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.posterArtUrl.Value(), - newElement_0_posterArtUrlInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_posterArtUrlInsideOptional, newElement_0_posterArtUrl); - } - jobject newElement_0_dvbiUrl; - if (!entry_0.dvbiUrl.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_dvbiUrl); - } - else - { - jobject newElement_0_dvbiUrlInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(entry_0.dvbiUrl.Value(), newElement_0_dvbiUrlInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_dvbiUrlInsideOptional, newElement_0_dvbiUrl); - } - jobject newElement_0_releaseDate; - if (!entry_0.releaseDate.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_releaseDate); - } - else - { - jobject newElement_0_releaseDateInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.releaseDate.Value(), - newElement_0_releaseDateInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_releaseDateInsideOptional, newElement_0_releaseDate); - } - jobject newElement_0_parentalGuidanceText; - if (!entry_0.parentalGuidanceText.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_parentalGuidanceText); - } - else - { - jobject newElement_0_parentalGuidanceTextInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.parentalGuidanceText.Value(), - newElement_0_parentalGuidanceTextInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_parentalGuidanceTextInsideOptional, - newElement_0_parentalGuidanceText); - } - jobject newElement_0_recordingFlag; - if (!entry_0.recordingFlag.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_recordingFlag); - } - else - { - jobject newElement_0_recordingFlagInsideOptional; - std::string newElement_0_recordingFlagInsideOptionalClassName = "java/lang/Long"; - std::string newElement_0_recordingFlagInsideOptionalCtorSignature = "(J)V"; - jlong jninewElement_0_recordingFlagInsideOptional = static_cast(entry_0.recordingFlag.Value().Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_recordingFlagInsideOptionalClassName.c_str(), - newElement_0_recordingFlagInsideOptionalCtorSignature.c_str(), jninewElement_0_recordingFlagInsideOptional, - newElement_0_recordingFlagInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_0_recordingFlagInsideOptional, newElement_0_recordingFlag); - } - jobject newElement_0_seriesInfo; - if (!entry_0.seriesInfo.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_seriesInfo); - } - else - { - jobject newElement_0_seriesInfoInsideOptional; - if (entry_0.seriesInfo.Value().IsNull()) - { - newElement_0_seriesInfoInsideOptional = nullptr; - } - else - { - jobject newElement_0_seriesInfoInsideOptional_season; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.seriesInfo.Value().Value().season, - newElement_0_seriesInfoInsideOptional_season)); - jobject newElement_0_seriesInfoInsideOptional_episode; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( - entry_0.seriesInfo.Value().Value().episode, newElement_0_seriesInfoInsideOptional_episode)); - - jclass seriesInfoStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterSeriesInfoStruct", seriesInfoStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterSeriesInfoStruct"); - return; - } - - jmethodID seriesInfoStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, seriesInfoStructStructClass_4, "", - "(Ljava/lang/String;Ljava/lang/String;)V", - &seriesInfoStructStructCtor_4); - if (err != CHIP_NO_ERROR || seriesInfoStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterSeriesInfoStruct constructor"); - return; - } - - newElement_0_seriesInfoInsideOptional = - env->NewObject(seriesInfoStructStructClass_4, seriesInfoStructStructCtor_4, - newElement_0_seriesInfoInsideOptional_season, newElement_0_seriesInfoInsideOptional_episode); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_seriesInfoInsideOptional, newElement_0_seriesInfo); - } - jobject newElement_0_categoryList; - if (!entry_0.categoryList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_categoryList); - } - else - { - jobject newElement_0_categoryListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_categoryListInsideOptional); - - auto iter_newElement_0_categoryListInsideOptional_3 = entry_0.categoryList.Value().begin(); - while (iter_newElement_0_categoryListInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_categoryListInsideOptional_3.GetValue(); - jobject newElement_3; - jobject newElement_3_category; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.category, newElement_3_category)); - jobject newElement_3_subCategory; - if (!entry_3.subCategory.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_subCategory); - } - else - { - jobject newElement_3_subCategoryInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.subCategory.Value(), - newElement_3_subCategoryInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(newElement_3_subCategoryInsideOptional, - newElement_3_subCategory); - } - - jclass programCategoryStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCategoryStruct", - programCategoryStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCategoryStruct"); - return; - } - - jmethodID programCategoryStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, programCategoryStructStructClass_4, "", - "(Ljava/lang/String;Ljava/util/Optional;)V", - &programCategoryStructStructCtor_4); - if (err != CHIP_NO_ERROR || programCategoryStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCategoryStruct constructor"); - return; - } - - newElement_3 = env->NewObject(programCategoryStructStructClass_4, programCategoryStructStructCtor_4, - newElement_3_category, newElement_3_subCategory); - chip::JniReferences::GetInstance().AddToList(newElement_0_categoryListInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_categoryListInsideOptional, newElement_0_categoryList); - } - jobject newElement_0_castList; - if (!entry_0.castList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_castList); - } - else - { - jobject newElement_0_castListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_castListInsideOptional); - - auto iter_newElement_0_castListInsideOptional_3 = entry_0.castList.Value().begin(); - while (iter_newElement_0_castListInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_castListInsideOptional_3.GetValue(); - jobject newElement_3; - jobject newElement_3_name; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.name, newElement_3_name)); - jobject newElement_3_role; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.role, newElement_3_role)); - - jclass programCastStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCastStruct", programCastStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCastStruct"); - return; - } - - jmethodID programCastStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, programCastStructStructClass_4, "", - "(Ljava/lang/String;Ljava/lang/String;)V", - &programCastStructStructCtor_4); - if (err != CHIP_NO_ERROR || programCastStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCastStruct constructor"); - return; - } - - newElement_3 = env->NewObject(programCastStructStructClass_4, programCastStructStructCtor_4, newElement_3_name, - newElement_3_role); - chip::JniReferences::GetInstance().AddToList(newElement_0_castListInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_castListInsideOptional, newElement_0_castList); - } - jobject newElement_0_externalIDList; - if (!entry_0.externalIDList.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_externalIDList); - } - else - { - jobject newElement_0_externalIDListInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_externalIDListInsideOptional); - - auto iter_newElement_0_externalIDListInsideOptional_3 = entry_0.externalIDList.Value().begin(); - while (iter_newElement_0_externalIDListInsideOptional_3.Next()) - { - auto & entry_3 = iter_newElement_0_externalIDListInsideOptional_3.GetValue(); - jobject newElement_3; - jobject newElement_3_name; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.name, newElement_3_name)); - jobject newElement_3_role; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.role, newElement_3_role)); - - jclass programCastStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCastStruct", programCastStructStructClass_4); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCastStruct"); - return; - } - - jmethodID programCastStructStructCtor_4; - err = chip::JniReferences::GetInstance().FindMethod(env, programCastStructStructClass_4, "", - "(Ljava/lang/String;Ljava/lang/String;)V", - &programCastStructStructCtor_4); - if (err != CHIP_NO_ERROR || programCastStructStructCtor_4 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCastStruct constructor"); - return; - } - - newElement_3 = env->NewObject(programCastStructStructClass_4, programCastStructStructCtor_4, newElement_3_name, - newElement_3_role); - chip::JniReferences::GetInstance().AddToList(newElement_0_externalIDListInsideOptional, newElement_3); - } - chip::JniReferences::GetInstance().CreateOptional(newElement_0_externalIDListInsideOptional, - newElement_0_externalIDList); - } - - jclass programStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramStruct", - programStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramStruct"); - return; - } - - jmethodID programStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod( - env, programStructStructClass_1, "", - "(Ljava/lang/String;Lchip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct;Ljava/lang/Long;Ljava/lang/" - "Long;Ljava/lang/String;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/" - "util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &programStructStructCtor_1); - if (err != CHIP_NO_ERROR || programStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramStruct constructor"); - return; - } - - newElement_0 = env->NewObject( - programStructStructClass_1, programStructStructCtor_1, newElement_0_identifier, newElement_0_channel, - newElement_0_startTime, newElement_0_endTime, newElement_0_title, newElement_0_subtitle, newElement_0_description, - newElement_0_audioLanguages, newElement_0_ratings, newElement_0_thumbnailUrl, newElement_0_posterArtUrl, - newElement_0_dvbiUrl, newElement_0_releaseDate, newElement_0_parentalGuidanceText, newElement_0_recordingFlag, - newElement_0_seriesInfo, newElement_0_categoryList, newElement_0_castList, newElement_0_externalIDList); - chip::JniReferences::GetInstance().AddToList(ProgramList, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Paging, ProgramList); -} -CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CHIPTargetNavigatorClusterNavigateTargetResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPTargetNavigatorClusterNavigateTargetResponseCallback::~CHIPTargetNavigatorClusterNavigateTargetResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPMediaPlaybackClusterPlaybackResponseCallback::CHIPMediaPlaybackClusterPlaybackResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPMediaPlaybackClusterPlaybackResponseCallback::~CHIPMediaPlaybackClusterPlaybackResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPMediaPlaybackClusterPlaybackResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPKeypadInputClusterSendKeyResponseCallback::CHIPKeypadInputClusterSendKeyResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPKeypadInputClusterSendKeyResponseCallback::~CHIPKeypadInputClusterSendKeyResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPKeypadInputClusterSendKeyResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status); -} -CHIPContentLauncherClusterLauncherResponseCallback::CHIPContentLauncherClusterLauncherResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPContentLauncherClusterLauncherResponseCallback::~CHIPContentLauncherClusterLauncherResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPContentLauncherClusterLauncherResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPApplicationLauncherClusterLauncherResponseCallback::CHIPApplicationLauncherClusterLauncherResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPApplicationLauncherClusterLauncherResponseCallback::~CHIPApplicationLauncherClusterLauncherResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPApplicationLauncherClusterLauncherResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - jbyteArray DataInsideOptionalByteArray = env->NewByteArray(static_cast(dataResponse.data.Value().size())); - env->SetByteArrayRegion(DataInsideOptionalByteArray, 0, static_cast(dataResponse.data.Value().size()), - reinterpret_cast(dataResponse.data.Value().data())); - DataInsideOptional = DataInsideOptionalByteArray; - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); -} -CHIPAccountLoginClusterGetSetupPINResponseCallback::CHIPAccountLoginClusterGetSetupPINResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPAccountLoginClusterGetSetupPINResponseCallback::~CHIPAccountLoginClusterGetSetupPINResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPAccountLoginClusterGetSetupPINResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject SetupPIN; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.setupPIN, SetupPIN)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, SetupPIN); -} -CHIPContentControlClusterResetPINResponseCallback::CHIPContentControlClusterResetPINResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPContentControlClusterResetPINResponseCallback::~CHIPContentControlClusterResetPINResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPContentControlClusterResetPINResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::ContentControl::Commands::ResetPINResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject PINCode; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.PINCode, PINCode)); - - env->CallVoidMethod(javaCallbackRef, javaMethod, PINCode); -} -CHIPContentAppObserverClusterContentAppMessageResponseCallback::CHIPContentAppObserverClusterContentAppMessageResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPContentAppObserverClusterContentAppMessageResponseCallback::~CHIPContentAppObserverClusterContentAppMessageResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPContentAppObserverClusterContentAppMessageResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessageResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject Status; - std::string StatusClassName = "java/lang/Integer"; - std::string StatusCtorSignature = "(I)V"; - jint jniStatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, - Status); - jobject Data; - if (!dataResponse.data.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); - } - else - { - jobject DataInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); - } - jobject EncodingHint; - if (!dataResponse.encodingHint.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, EncodingHint); - } - else - { - jobject EncodingHintInsideOptional; - LogErrorOnFailure( - chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.encodingHint.Value(), EncodingHintInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(EncodingHintInsideOptional, EncodingHint); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data, EncodingHint); -} -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback:: -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback::~ -CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback::CallbackFn( - void * context, - const chip::app::Clusters::ElectricalMeasurement::Commands::GetProfileInfoResponseCommand::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject profileCount; - std::string profileCountClassName = "java/lang/Integer"; - std::string profileCountCtorSignature = "(I)V"; - jint jniprofileCount = static_cast(dataResponse.profileCount); - chip::JniReferences::GetInstance().CreateBoxedObject(profileCountClassName.c_str(), profileCountCtorSignature.c_str(), - jniprofileCount, profileCount); - jobject profileIntervalPeriod; - std::string profileIntervalPeriodClassName = "java/lang/Integer"; - std::string profileIntervalPeriodCtorSignature = "(I)V"; - jint jniprofileIntervalPeriod = static_cast(dataResponse.profileIntervalPeriod); - chip::JniReferences::GetInstance().CreateBoxedObject(profileIntervalPeriodClassName.c_str(), - profileIntervalPeriodCtorSignature.c_str(), jniprofileIntervalPeriod, - profileIntervalPeriod); - jobject maxNumberOfIntervals; - std::string maxNumberOfIntervalsClassName = "java/lang/Integer"; - std::string maxNumberOfIntervalsCtorSignature = "(I)V"; - jint jnimaxNumberOfIntervals = static_cast(dataResponse.maxNumberOfIntervals); - chip::JniReferences::GetInstance().CreateBoxedObject(maxNumberOfIntervalsClassName.c_str(), - maxNumberOfIntervalsCtorSignature.c_str(), jnimaxNumberOfIntervals, - maxNumberOfIntervals); - jobject listOfAttributes; - chip::JniReferences::GetInstance().CreateArrayList(listOfAttributes); - - auto iter_listOfAttributes_0 = dataResponse.listOfAttributes.begin(); - while (iter_listOfAttributes_0.Next()) - { - auto & entry_0 = iter_listOfAttributes_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint 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(listOfAttributes, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, profileCount, profileIntervalPeriod, maxNumberOfIntervals, listOfAttributes); -} -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback:: -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback::~ -CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback::CallbackFn( - void * context, - const chip::app::Clusters::ElectricalMeasurement::Commands::GetMeasurementProfileResponseCommand::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject startTime; - std::string startTimeClassName = "java/lang/Long"; - std::string startTimeCtorSignature = "(J)V"; - jlong jnistartTime = static_cast(dataResponse.startTime); - chip::JniReferences::GetInstance().CreateBoxedObject(startTimeClassName.c_str(), startTimeCtorSignature.c_str(), - jnistartTime, startTime); - jobject status; - std::string statusClassName = "java/lang/Integer"; - std::string statusCtorSignature = "(I)V"; - jint jnistatus = static_cast(dataResponse.status); - chip::JniReferences::GetInstance().CreateBoxedObject(statusClassName.c_str(), statusCtorSignature.c_str(), jnistatus, - status); - jobject profileIntervalPeriod; - std::string profileIntervalPeriodClassName = "java/lang/Integer"; - std::string profileIntervalPeriodCtorSignature = "(I)V"; - jint jniprofileIntervalPeriod = static_cast(dataResponse.profileIntervalPeriod); - chip::JniReferences::GetInstance().CreateBoxedObject(profileIntervalPeriodClassName.c_str(), - profileIntervalPeriodCtorSignature.c_str(), jniprofileIntervalPeriod, - profileIntervalPeriod); - jobject numberOfIntervalsDelivered; - std::string numberOfIntervalsDeliveredClassName = "java/lang/Integer"; - std::string numberOfIntervalsDeliveredCtorSignature = "(I)V"; - jint jninumberOfIntervalsDelivered = static_cast(dataResponse.numberOfIntervalsDelivered); - chip::JniReferences::GetInstance().CreateBoxedObject(numberOfIntervalsDeliveredClassName.c_str(), - numberOfIntervalsDeliveredCtorSignature.c_str(), - jninumberOfIntervalsDelivered, numberOfIntervalsDelivered); - jobject attributeId; - std::string attributeIdClassName = "java/lang/Integer"; - std::string attributeIdCtorSignature = "(I)V"; - jint jniattributeId = static_cast(dataResponse.attributeId); - chip::JniReferences::GetInstance().CreateBoxedObject(attributeIdClassName.c_str(), attributeIdCtorSignature.c_str(), - jniattributeId, attributeId); - jobject intervals; - chip::JniReferences::GetInstance().CreateArrayList(intervals); - - auto iter_intervals_0 = dataResponse.intervals.begin(); - while (iter_intervals_0.Next()) - { - auto & entry_0 = iter_intervals_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint 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(intervals, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, startTime, status, profileIntervalPeriod, numberOfIntervalsDelivered, - attributeId, intervals); -} -CHIPUnitTestingClusterTestSpecificResponseCallback::CHIPUnitTestingClusterTestSpecificResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestSpecificResponseCallback::~CHIPUnitTestingClusterTestSpecificResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestSpecificResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Integer"; - std::string returnValueCtorSignature = "(I)V"; - jint jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -CHIPUnitTestingClusterTestAddArgumentsResponseCallback::CHIPUnitTestingClusterTestAddArgumentsResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestAddArgumentsResponseCallback::~CHIPUnitTestingClusterTestAddArgumentsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestAddArgumentsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Integer"; - std::string returnValueCtorSignature = "(I)V"; - jint jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::CHIPUnitTestingClusterTestSimpleArgumentResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::~CHIPUnitTestingClusterTestSimpleArgumentResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Boolean"; - std::string returnValueCtorSignature = "(Z)V"; - jboolean jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::~CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", - "(Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/" - "ArrayList;Ljava/lang/Integer;Ljava/lang/Boolean;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - chip::JniReferences::GetInstance().CreateArrayList(arg1); - - auto iter_arg1_0 = dataResponse.arg1.begin(); - while (iter_arg1_0.Next()) - { - auto & entry_0 = iter_arg1_0.GetValue(); - jobject newElement_0; - jobject newElement_0_a; - std::string newElement_0_aClassName = "java/lang/Integer"; - std::string newElement_0_aCtorSignature = "(I)V"; - jint jninewElement_0_a = static_cast(entry_0.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_aClassName.c_str(), newElement_0_aCtorSignature.c_str(), jninewElement_0_a, newElement_0_a); - jobject newElement_0_b; - std::string newElement_0_bClassName = "java/lang/Boolean"; - std::string newElement_0_bCtorSignature = "(Z)V"; - jboolean jninewElement_0_b = static_cast(entry_0.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_bClassName.c_str(), newElement_0_bCtorSignature.c_str(), jninewElement_0_b, newElement_0_b); - jobject newElement_0_c; - jobject newElement_0_c_a; - std::string newElement_0_c_aClassName = "java/lang/Integer"; - std::string newElement_0_c_aCtorSignature = "(I)V"; - jint jninewElement_0_c_a = static_cast(entry_0.c.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_aClassName.c_str(), newElement_0_c_aCtorSignature.c_str(), jninewElement_0_c_a, newElement_0_c_a); - jobject newElement_0_c_b; - std::string newElement_0_c_bClassName = "java/lang/Boolean"; - std::string newElement_0_c_bCtorSignature = "(Z)V"; - jboolean jninewElement_0_c_b = static_cast(entry_0.c.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_bClassName.c_str(), newElement_0_c_bCtorSignature.c_str(), jninewElement_0_c_b, newElement_0_c_b); - jobject newElement_0_c_c; - std::string newElement_0_c_cClassName = "java/lang/Integer"; - std::string newElement_0_c_cCtorSignature = "(I)V"; - jint jninewElement_0_c_c = static_cast(entry_0.c.c); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_cClassName.c_str(), newElement_0_c_cCtorSignature.c_str(), jninewElement_0_c_c, newElement_0_c_c); - jobject newElement_0_c_d; - jbyteArray newElement_0_c_dByteArray = env->NewByteArray(static_cast(entry_0.c.d.size())); - env->SetByteArrayRegion(newElement_0_c_dByteArray, 0, static_cast(entry_0.c.d.size()), - reinterpret_cast(entry_0.c.d.data())); - newElement_0_c_d = newElement_0_c_dByteArray; - jobject newElement_0_c_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.c.e, newElement_0_c_e)); - jobject newElement_0_c_f; - std::string newElement_0_c_fClassName = "java/lang/Integer"; - std::string newElement_0_c_fCtorSignature = "(I)V"; - jint jninewElement_0_c_f = static_cast(entry_0.c.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_fClassName.c_str(), newElement_0_c_fCtorSignature.c_str(), jninewElement_0_c_f, newElement_0_c_f); - jobject newElement_0_c_g; - std::string newElement_0_c_gClassName = "java/lang/Float"; - std::string newElement_0_c_gCtorSignature = "(F)V"; - jfloat jninewElement_0_c_g = static_cast(entry_0.c.g); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_gClassName.c_str(), newElement_0_c_gCtorSignature.c_str(), jninewElement_0_c_g, newElement_0_c_g); - jobject newElement_0_c_h; - std::string newElement_0_c_hClassName = "java/lang/Double"; - std::string newElement_0_c_hCtorSignature = "(D)V"; - jdouble jninewElement_0_c_h = static_cast(entry_0.c.h); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_c_hClassName.c_str(), newElement_0_c_hCtorSignature.c_str(), jninewElement_0_c_h, newElement_0_c_h); - - jclass simpleStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_2); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_2, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_2); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - newElement_0_c = env->NewObject(simpleStructStructClass_2, simpleStructStructCtor_2, newElement_0_c_a, newElement_0_c_b, - newElement_0_c_c, newElement_0_c_d, newElement_0_c_e, newElement_0_c_f, newElement_0_c_g, - newElement_0_c_h); - jobject newElement_0_d; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_d); - - auto iter_newElement_0_d_2 = entry_0.d.begin(); - while (iter_newElement_0_d_2.Next()) - { - auto & entry_2 = iter_newElement_0_d_2.GetValue(); - jobject newElement_2; - jobject newElement_2_a; - std::string newElement_2_aClassName = "java/lang/Integer"; - std::string newElement_2_aCtorSignature = "(I)V"; - jint jninewElement_2_a = static_cast(entry_2.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_aClassName.c_str(), newElement_2_aCtorSignature.c_str(), jninewElement_2_a, newElement_2_a); - jobject newElement_2_b; - std::string newElement_2_bClassName = "java/lang/Boolean"; - std::string newElement_2_bCtorSignature = "(Z)V"; - jboolean jninewElement_2_b = static_cast(entry_2.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_bClassName.c_str(), newElement_2_bCtorSignature.c_str(), jninewElement_2_b, newElement_2_b); - jobject newElement_2_c; - std::string newElement_2_cClassName = "java/lang/Integer"; - std::string newElement_2_cCtorSignature = "(I)V"; - jint jninewElement_2_c = static_cast(entry_2.c); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_cClassName.c_str(), newElement_2_cCtorSignature.c_str(), jninewElement_2_c, newElement_2_c); - jobject newElement_2_d; - jbyteArray newElement_2_dByteArray = env->NewByteArray(static_cast(entry_2.d.size())); - env->SetByteArrayRegion(newElement_2_dByteArray, 0, static_cast(entry_2.d.size()), - reinterpret_cast(entry_2.d.data())); - newElement_2_d = newElement_2_dByteArray; - jobject newElement_2_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_2.e, newElement_2_e)); - jobject newElement_2_f; - std::string newElement_2_fClassName = "java/lang/Integer"; - std::string newElement_2_fCtorSignature = "(I)V"; - jint jninewElement_2_f = static_cast(entry_2.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_fClassName.c_str(), newElement_2_fCtorSignature.c_str(), jninewElement_2_f, newElement_2_f); - jobject newElement_2_g; - std::string newElement_2_gClassName = "java/lang/Float"; - std::string newElement_2_gCtorSignature = "(F)V"; - jfloat jninewElement_2_g = static_cast(entry_2.g); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_gClassName.c_str(), newElement_2_gCtorSignature.c_str(), jninewElement_2_g, newElement_2_g); - jobject newElement_2_h; - std::string newElement_2_hClassName = "java/lang/Double"; - std::string newElement_2_hCtorSignature = "(D)V"; - jdouble jninewElement_2_h = static_cast(entry_2.h); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_hClassName.c_str(), newElement_2_hCtorSignature.c_str(), jninewElement_2_h, newElement_2_h); - - jclass simpleStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_3); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_3; - err = chip::JniReferences::GetInstance().FindMethod( - env, simpleStructStructClass_3, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_3); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_3 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - newElement_2 = - env->NewObject(simpleStructStructClass_3, simpleStructStructCtor_3, newElement_2_a, newElement_2_b, newElement_2_c, - newElement_2_d, newElement_2_e, newElement_2_f, newElement_2_g, newElement_2_h); - chip::JniReferences::GetInstance().AddToList(newElement_0_d, newElement_2); - } - jobject newElement_0_e; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_e); - - auto iter_newElement_0_e_2 = entry_0.e.begin(); - while (iter_newElement_0_e_2.Next()) - { - auto & entry_2 = iter_newElement_0_e_2.GetValue(); - jobject newElement_2; - std::string newElement_2ClassName = "java/lang/Long"; - std::string newElement_2CtorSignature = "(J)V"; - jlong jninewElement_2 = static_cast(entry_2); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2ClassName.c_str(), newElement_2CtorSignature.c_str(), jninewElement_2, newElement_2); - chip::JniReferences::GetInstance().AddToList(newElement_0_e, newElement_2); - } - jobject newElement_0_f; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_f); - - auto iter_newElement_0_f_2 = entry_0.f.begin(); - while (iter_newElement_0_f_2.Next()) - { - auto & entry_2 = iter_newElement_0_f_2.GetValue(); - jobject newElement_2; - jbyteArray newElement_2ByteArray = env->NewByteArray(static_cast(entry_2.size())); - env->SetByteArrayRegion(newElement_2ByteArray, 0, static_cast(entry_2.size()), - reinterpret_cast(entry_2.data())); - newElement_2 = newElement_2ByteArray; - chip::JniReferences::GetInstance().AddToList(newElement_0_f, newElement_2); - } - jobject newElement_0_g; - chip::JniReferences::GetInstance().CreateArrayList(newElement_0_g); - - auto iter_newElement_0_g_2 = entry_0.g.begin(); - while (iter_newElement_0_g_2.Next()) - { - auto & entry_2 = iter_newElement_0_g_2.GetValue(); - jobject newElement_2; - std::string newElement_2ClassName = "java/lang/Integer"; - std::string newElement_2CtorSignature = "(I)V"; - jint jninewElement_2 = static_cast(entry_2); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2ClassName.c_str(), newElement_2CtorSignature.c_str(), jninewElement_2, newElement_2); - chip::JniReferences::GetInstance().AddToList(newElement_0_g, newElement_2); - } - - jclass nestedStructListStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterNestedStructList", nestedStructListStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterNestedStructList"); - return; - } - - jmethodID nestedStructListStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod( - env, nestedStructListStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Lchip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct;Ljava/util/" - "ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;)V", - &nestedStructListStructCtor_1); - if (err != CHIP_NO_ERROR || nestedStructListStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterNestedStructList constructor"); - return; - } - - newElement_0 = env->NewObject(nestedStructListStructClass_1, nestedStructListStructCtor_1, newElement_0_a, newElement_0_b, - newElement_0_c, newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g); - chip::JniReferences::GetInstance().AddToList(arg1, newElement_0); - } - jobject arg2; - chip::JniReferences::GetInstance().CreateArrayList(arg2); - - auto iter_arg2_0 = dataResponse.arg2.begin(); - while (iter_arg2_0.Next()) - { - auto & entry_0 = iter_arg2_0.GetValue(); - jobject newElement_0; - jobject newElement_0_a; - std::string newElement_0_aClassName = "java/lang/Integer"; - std::string newElement_0_aCtorSignature = "(I)V"; - jint jninewElement_0_a = static_cast(entry_0.a); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_aClassName.c_str(), newElement_0_aCtorSignature.c_str(), jninewElement_0_a, newElement_0_a); - jobject newElement_0_b; - std::string newElement_0_bClassName = "java/lang/Boolean"; - std::string newElement_0_bCtorSignature = "(Z)V"; - jboolean jninewElement_0_b = static_cast(entry_0.b); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_bClassName.c_str(), newElement_0_bCtorSignature.c_str(), jninewElement_0_b, newElement_0_b); - jobject newElement_0_c; - std::string newElement_0_cClassName = "java/lang/Integer"; - std::string newElement_0_cCtorSignature = "(I)V"; - jint jninewElement_0_c = static_cast(entry_0.c); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_cClassName.c_str(), newElement_0_cCtorSignature.c_str(), jninewElement_0_c, newElement_0_c); - jobject newElement_0_d; - jbyteArray newElement_0_dByteArray = env->NewByteArray(static_cast(entry_0.d.size())); - env->SetByteArrayRegion(newElement_0_dByteArray, 0, static_cast(entry_0.d.size()), - reinterpret_cast(entry_0.d.data())); - newElement_0_d = newElement_0_dByteArray; - jobject newElement_0_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.e, newElement_0_e)); - jobject newElement_0_f; - std::string newElement_0_fClassName = "java/lang/Integer"; - std::string newElement_0_fCtorSignature = "(I)V"; - jint jninewElement_0_f = static_cast(entry_0.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_fClassName.c_str(), newElement_0_fCtorSignature.c_str(), jninewElement_0_f, newElement_0_f); - jobject newElement_0_g; - std::string newElement_0_gClassName = "java/lang/Float"; - std::string newElement_0_gCtorSignature = "(F)V"; - jfloat jninewElement_0_g = static_cast(entry_0.g); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_gClassName.c_str(), newElement_0_gCtorSignature.c_str(), jninewElement_0_g, newElement_0_g); - jobject newElement_0_h; - std::string newElement_0_hClassName = "java/lang/Double"; - std::string newElement_0_hCtorSignature = "(D)V"; - jdouble jninewElement_0_h = static_cast(entry_0.h); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_hClassName.c_str(), newElement_0_hCtorSignature.c_str(), jninewElement_0_h, newElement_0_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - newElement_0 = - env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, newElement_0_a, newElement_0_b, newElement_0_c, - newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g, newElement_0_h); - chip::JniReferences::GetInstance().AddToList(arg2, newElement_0); - } - jobject arg3; - chip::JniReferences::GetInstance().CreateArrayList(arg3); - - auto iter_arg3_0 = dataResponse.arg3.begin(); - while (iter_arg3_0.Next()) - { - auto & entry_0 = iter_arg3_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint 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(arg3, newElement_0); - } - jobject arg4; - chip::JniReferences::GetInstance().CreateArrayList(arg4); - - auto iter_arg4_0 = dataResponse.arg4.begin(); - while (iter_arg4_0.Next()) - { - auto & entry_0 = iter_arg4_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Boolean"; - std::string newElement_0CtorSignature = "(Z)V"; - jboolean 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(arg4, newElement_0); - } - jobject arg5; - std::string arg5ClassName = "java/lang/Integer"; - std::string arg5CtorSignature = "(I)V"; - jint jniarg5 = static_cast(dataResponse.arg5); - chip::JniReferences::GetInstance().CreateBoxedObject(arg5ClassName.c_str(), arg5CtorSignature.c_str(), jniarg5, arg5); - jobject arg6; - std::string arg6ClassName = "java/lang/Boolean"; - std::string arg6CtorSignature = "(Z)V"; - jboolean jniarg6 = static_cast(dataResponse.arg6); - chip::JniReferences::GetInstance().CreateBoxedObject(arg6ClassName.c_str(), arg6CtorSignature.c_str(), jniarg6, arg6); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, arg2, arg3, arg4, arg5, arg6); -} -CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::CHIPUnitTestingClusterTestListInt8UReverseResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::~CHIPUnitTestingClusterTestListInt8UReverseResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - chip::JniReferences::GetInstance().CreateArrayList(arg1); - - auto iter_arg1_0 = dataResponse.arg1.begin(); - while (iter_arg1_0.Next()) - { - auto & entry_0 = iter_arg1_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Integer"; - std::string newElement_0CtorSignature = "(I)V"; - jint 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(arg1, newElement_0); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1); -} -CHIPUnitTestingClusterTestEnumsResponseCallback::CHIPUnitTestingClusterTestEnumsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestEnumsResponseCallback::~CHIPUnitTestingClusterTestEnumsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestEnumsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - std::string arg1ClassName = "java/lang/Integer"; - std::string arg1CtorSignature = "(I)V"; - jint jniarg1 = static_cast(dataResponse.arg1); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1ClassName.c_str(), arg1CtorSignature.c_str(), jniarg1, arg1); - jobject arg2; - std::string arg2ClassName = "java/lang/Integer"; - std::string arg2CtorSignature = "(I)V"; - jint jniarg2 = static_cast(dataResponse.arg2); - chip::JniReferences::GetInstance().CreateBoxedObject(arg2ClassName.c_str(), arg2CtorSignature.c_str(), jniarg2, arg2); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, arg2); -} -CHIPUnitTestingClusterTestNullableOptionalResponseCallback::CHIPUnitTestingClusterTestNullableOptionalResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestNullableOptionalResponseCallback::~CHIPUnitTestingClusterTestNullableOptionalResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestNullableOptionalResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject wasPresent; - std::string wasPresentClassName = "java/lang/Boolean"; - std::string wasPresentCtorSignature = "(Z)V"; - jboolean jniwasPresent = static_cast(dataResponse.wasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(wasPresentClassName.c_str(), wasPresentCtorSignature.c_str(), - jniwasPresent, wasPresent); - jobject wasNull; - if (!dataResponse.wasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, wasNull); - } - else - { - jobject wasNullInsideOptional; - std::string wasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string wasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniwasNullInsideOptional = static_cast(dataResponse.wasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(wasNullInsideOptionalClassName.c_str(), - wasNullInsideOptionalCtorSignature.c_str(), - jniwasNullInsideOptional, wasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(wasNullInsideOptional, wasNull); - } - jobject value; - if (!dataResponse.value.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value); - } - else - { - jobject valueInsideOptional; - std::string valueInsideOptionalClassName = "java/lang/Integer"; - std::string valueInsideOptionalCtorSignature = "(I)V"; - jint jnivalueInsideOptional = static_cast(dataResponse.value.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueInsideOptionalClassName.c_str(), - valueInsideOptionalCtorSignature.c_str(), jnivalueInsideOptional, - valueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(valueInsideOptional, value); - } - jobject originalValue; - if (!dataResponse.originalValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, originalValue); - } - else - { - jobject originalValueInsideOptional; - if (dataResponse.originalValue.Value().IsNull()) - { - originalValueInsideOptional = nullptr; - } - else - { - std::string originalValueInsideOptionalClassName = "java/lang/Integer"; - std::string originalValueInsideOptionalCtorSignature = "(I)V"; - jint jnioriginalValueInsideOptional = static_cast(dataResponse.originalValue.Value().Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(originalValueInsideOptionalClassName.c_str(), - originalValueInsideOptionalCtorSignature.c_str(), - jnioriginalValueInsideOptional, originalValueInsideOptional); - } - chip::JniReferences::GetInstance().CreateOptional(originalValueInsideOptional, originalValue); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, wasPresent, wasNull, value, originalValue); -} -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback:: -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::~ -CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", - "(Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/" - "Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/" - "Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/" - "Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/" - "Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject NullableIntWasNull; - std::string NullableIntWasNullClassName = "java/lang/Boolean"; - std::string NullableIntWasNullCtorSignature = "(Z)V"; - jboolean jniNullableIntWasNull = static_cast(dataResponse.nullableIntWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableIntWasNullClassName.c_str(), NullableIntWasNullCtorSignature.c_str(), jniNullableIntWasNull, NullableIntWasNull); - jobject NullableIntValue; - if (!dataResponse.nullableIntValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableIntValue); - } - else - { - jobject NullableIntValueInsideOptional; - std::string NullableIntValueInsideOptionalClassName = "java/lang/Integer"; - std::string NullableIntValueInsideOptionalCtorSignature = "(I)V"; - jint jniNullableIntValueInsideOptional = static_cast(dataResponse.nullableIntValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableIntValueInsideOptionalClassName.c_str(), NullableIntValueInsideOptionalCtorSignature.c_str(), - jniNullableIntValueInsideOptional, NullableIntValueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableIntValueInsideOptional, NullableIntValue); - } - jobject OptionalIntWasPresent; - std::string OptionalIntWasPresentClassName = "java/lang/Boolean"; - std::string OptionalIntWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalIntWasPresent = static_cast(dataResponse.optionalIntWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalIntWasPresentClassName.c_str(), - OptionalIntWasPresentCtorSignature.c_str(), - jniOptionalIntWasPresent, OptionalIntWasPresent); - jobject OptionalIntValue; - if (!dataResponse.optionalIntValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalIntValue); - } - else - { - jobject OptionalIntValueInsideOptional; - std::string OptionalIntValueInsideOptionalClassName = "java/lang/Integer"; - std::string OptionalIntValueInsideOptionalCtorSignature = "(I)V"; - jint jniOptionalIntValueInsideOptional = static_cast(dataResponse.optionalIntValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalIntValueInsideOptionalClassName.c_str(), OptionalIntValueInsideOptionalCtorSignature.c_str(), - jniOptionalIntValueInsideOptional, OptionalIntValueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(OptionalIntValueInsideOptional, OptionalIntValue); - } - jobject NullableOptionalIntWasPresent; - std::string NullableOptionalIntWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalIntWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalIntWasPresent = static_cast(dataResponse.nullableOptionalIntWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalIntWasPresentClassName.c_str(), - NullableOptionalIntWasPresentCtorSignature.c_str(), - jniNullableOptionalIntWasPresent, NullableOptionalIntWasPresent); - jobject NullableOptionalIntWasNull; - if (!dataResponse.nullableOptionalIntWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalIntWasNull); - } - else - { - jobject NullableOptionalIntWasNullInsideOptional; - std::string NullableOptionalIntWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalIntWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalIntWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalIntWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalIntWasNullInsideOptionalClassName.c_str(), - NullableOptionalIntWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalIntWasNullInsideOptional, - NullableOptionalIntWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalIntWasNullInsideOptional, NullableOptionalIntWasNull); - } - jobject NullableOptionalIntValue; - if (!dataResponse.nullableOptionalIntValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalIntValue); - } - else - { - jobject NullableOptionalIntValueInsideOptional; - std::string NullableOptionalIntValueInsideOptionalClassName = "java/lang/Integer"; - std::string NullableOptionalIntValueInsideOptionalCtorSignature = "(I)V"; - jint jniNullableOptionalIntValueInsideOptional = static_cast(dataResponse.nullableOptionalIntValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalIntValueInsideOptionalClassName.c_str(), NullableOptionalIntValueInsideOptionalCtorSignature.c_str(), - jniNullableOptionalIntValueInsideOptional, NullableOptionalIntValueInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalIntValueInsideOptional, NullableOptionalIntValue); - } - jobject NullableStringWasNull; - std::string NullableStringWasNullClassName = "java/lang/Boolean"; - std::string NullableStringWasNullCtorSignature = "(Z)V"; - jboolean jniNullableStringWasNull = static_cast(dataResponse.nullableStringWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableStringWasNullClassName.c_str(), - NullableStringWasNullCtorSignature.c_str(), - jniNullableStringWasNull, NullableStringWasNull); - jobject NullableStringValue; - if (!dataResponse.nullableStringValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableStringValue); - } - else - { - jobject NullableStringValueInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStringValue.Value(), - NullableStringValueInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(NullableStringValueInsideOptional, NullableStringValue); - } - jobject OptionalStringWasPresent; - std::string OptionalStringWasPresentClassName = "java/lang/Boolean"; - std::string OptionalStringWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalStringWasPresent = static_cast(dataResponse.optionalStringWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalStringWasPresentClassName.c_str(), - OptionalStringWasPresentCtorSignature.c_str(), - jniOptionalStringWasPresent, OptionalStringWasPresent); - jobject OptionalStringValue; - if (!dataResponse.optionalStringValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalStringValue); - } - else - { - jobject OptionalStringValueInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStringValue.Value(), - OptionalStringValueInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(OptionalStringValueInsideOptional, OptionalStringValue); - } - jobject NullableOptionalStringWasPresent; - std::string NullableOptionalStringWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalStringWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStringWasPresent = static_cast(dataResponse.nullableOptionalStringWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStringWasPresentClassName.c_str(), NullableOptionalStringWasPresentCtorSignature.c_str(), - jniNullableOptionalStringWasPresent, NullableOptionalStringWasPresent); - jobject NullableOptionalStringWasNull; - if (!dataResponse.nullableOptionalStringWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStringWasNull); - } - else - { - jobject NullableOptionalStringWasNullInsideOptional; - std::string NullableOptionalStringWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalStringWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStringWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalStringWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStringWasNullInsideOptionalClassName.c_str(), - NullableOptionalStringWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalStringWasNullInsideOptional, - NullableOptionalStringWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringWasNullInsideOptional, - NullableOptionalStringWasNull); - } - jobject NullableOptionalStringValue; - if (!dataResponse.nullableOptionalStringValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStringValue); - } - else - { - jobject NullableOptionalStringValueInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStringValue.Value(), - NullableOptionalStringValueInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringValueInsideOptional, NullableOptionalStringValue); - } - jobject NullableStructWasNull; - std::string NullableStructWasNullClassName = "java/lang/Boolean"; - std::string NullableStructWasNullCtorSignature = "(Z)V"; - jboolean jniNullableStructWasNull = static_cast(dataResponse.nullableStructWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableStructWasNullClassName.c_str(), - NullableStructWasNullCtorSignature.c_str(), - jniNullableStructWasNull, NullableStructWasNull); - jobject NullableStructValue; - if (!dataResponse.nullableStructValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableStructValue); - } - else - { - jobject NullableStructValueInsideOptional; - jobject NullableStructValueInsideOptional_a; - std::string NullableStructValueInsideOptional_aClassName = "java/lang/Integer"; - std::string NullableStructValueInsideOptional_aCtorSignature = "(I)V"; - jint jniNullableStructValueInsideOptional_a = static_cast(dataResponse.nullableStructValue.Value().a); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_aClassName.c_str(), NullableStructValueInsideOptional_aCtorSignature.c_str(), - jniNullableStructValueInsideOptional_a, NullableStructValueInsideOptional_a); - jobject NullableStructValueInsideOptional_b; - std::string NullableStructValueInsideOptional_bClassName = "java/lang/Boolean"; - std::string NullableStructValueInsideOptional_bCtorSignature = "(Z)V"; - jboolean jniNullableStructValueInsideOptional_b = static_cast(dataResponse.nullableStructValue.Value().b); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_bClassName.c_str(), NullableStructValueInsideOptional_bCtorSignature.c_str(), - jniNullableStructValueInsideOptional_b, NullableStructValueInsideOptional_b); - jobject NullableStructValueInsideOptional_c; - std::string NullableStructValueInsideOptional_cClassName = "java/lang/Integer"; - std::string NullableStructValueInsideOptional_cCtorSignature = "(I)V"; - jint jniNullableStructValueInsideOptional_c = static_cast(dataResponse.nullableStructValue.Value().c); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_cClassName.c_str(), NullableStructValueInsideOptional_cCtorSignature.c_str(), - jniNullableStructValueInsideOptional_c, NullableStructValueInsideOptional_c); - jobject NullableStructValueInsideOptional_d; - jbyteArray NullableStructValueInsideOptional_dByteArray = - env->NewByteArray(static_cast(dataResponse.nullableStructValue.Value().d.size())); - env->SetByteArrayRegion(NullableStructValueInsideOptional_dByteArray, 0, - static_cast(dataResponse.nullableStructValue.Value().d.size()), - reinterpret_cast(dataResponse.nullableStructValue.Value().d.data())); - NullableStructValueInsideOptional_d = NullableStructValueInsideOptional_dByteArray; - jobject NullableStructValueInsideOptional_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStructValue.Value().e, - NullableStructValueInsideOptional_e)); - jobject NullableStructValueInsideOptional_f; - std::string NullableStructValueInsideOptional_fClassName = "java/lang/Integer"; - std::string NullableStructValueInsideOptional_fCtorSignature = "(I)V"; - jint jniNullableStructValueInsideOptional_f = static_cast(dataResponse.nullableStructValue.Value().f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_fClassName.c_str(), NullableStructValueInsideOptional_fCtorSignature.c_str(), - jniNullableStructValueInsideOptional_f, NullableStructValueInsideOptional_f); - jobject NullableStructValueInsideOptional_g; - std::string NullableStructValueInsideOptional_gClassName = "java/lang/Float"; - std::string NullableStructValueInsideOptional_gCtorSignature = "(F)V"; - jfloat jniNullableStructValueInsideOptional_g = static_cast(dataResponse.nullableStructValue.Value().g); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_gClassName.c_str(), NullableStructValueInsideOptional_gCtorSignature.c_str(), - jniNullableStructValueInsideOptional_g, NullableStructValueInsideOptional_g); - jobject NullableStructValueInsideOptional_h; - std::string NullableStructValueInsideOptional_hClassName = "java/lang/Double"; - std::string NullableStructValueInsideOptional_hCtorSignature = "(D)V"; - jdouble jniNullableStructValueInsideOptional_h = static_cast(dataResponse.nullableStructValue.Value().h); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableStructValueInsideOptional_hClassName.c_str(), NullableStructValueInsideOptional_hCtorSignature.c_str(), - jniNullableStructValueInsideOptional_h, NullableStructValueInsideOptional_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - NullableStructValueInsideOptional = env->NewObject( - simpleStructStructClass_1, simpleStructStructCtor_1, NullableStructValueInsideOptional_a, - NullableStructValueInsideOptional_b, NullableStructValueInsideOptional_c, NullableStructValueInsideOptional_d, - NullableStructValueInsideOptional_e, NullableStructValueInsideOptional_f, NullableStructValueInsideOptional_g, - NullableStructValueInsideOptional_h); - chip::JniReferences::GetInstance().CreateOptional(NullableStructValueInsideOptional, NullableStructValue); - } - jobject OptionalStructWasPresent; - std::string OptionalStructWasPresentClassName = "java/lang/Boolean"; - std::string OptionalStructWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalStructWasPresent = static_cast(dataResponse.optionalStructWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalStructWasPresentClassName.c_str(), - OptionalStructWasPresentCtorSignature.c_str(), - jniOptionalStructWasPresent, OptionalStructWasPresent); - jobject OptionalStructValue; - if (!dataResponse.optionalStructValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalStructValue); - } - else - { - jobject OptionalStructValueInsideOptional; - jobject OptionalStructValueInsideOptional_a; - std::string OptionalStructValueInsideOptional_aClassName = "java/lang/Integer"; - std::string OptionalStructValueInsideOptional_aCtorSignature = "(I)V"; - jint jniOptionalStructValueInsideOptional_a = static_cast(dataResponse.optionalStructValue.Value().a); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_aClassName.c_str(), OptionalStructValueInsideOptional_aCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_a, OptionalStructValueInsideOptional_a); - jobject OptionalStructValueInsideOptional_b; - std::string OptionalStructValueInsideOptional_bClassName = "java/lang/Boolean"; - std::string OptionalStructValueInsideOptional_bCtorSignature = "(Z)V"; - jboolean jniOptionalStructValueInsideOptional_b = static_cast(dataResponse.optionalStructValue.Value().b); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_bClassName.c_str(), OptionalStructValueInsideOptional_bCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_b, OptionalStructValueInsideOptional_b); - jobject OptionalStructValueInsideOptional_c; - std::string OptionalStructValueInsideOptional_cClassName = "java/lang/Integer"; - std::string OptionalStructValueInsideOptional_cCtorSignature = "(I)V"; - jint jniOptionalStructValueInsideOptional_c = static_cast(dataResponse.optionalStructValue.Value().c); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_cClassName.c_str(), OptionalStructValueInsideOptional_cCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_c, OptionalStructValueInsideOptional_c); - jobject OptionalStructValueInsideOptional_d; - jbyteArray OptionalStructValueInsideOptional_dByteArray = - env->NewByteArray(static_cast(dataResponse.optionalStructValue.Value().d.size())); - env->SetByteArrayRegion(OptionalStructValueInsideOptional_dByteArray, 0, - static_cast(dataResponse.optionalStructValue.Value().d.size()), - reinterpret_cast(dataResponse.optionalStructValue.Value().d.data())); - OptionalStructValueInsideOptional_d = OptionalStructValueInsideOptional_dByteArray; - jobject OptionalStructValueInsideOptional_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStructValue.Value().e, - OptionalStructValueInsideOptional_e)); - jobject OptionalStructValueInsideOptional_f; - std::string OptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; - std::string OptionalStructValueInsideOptional_fCtorSignature = "(I)V"; - jint jniOptionalStructValueInsideOptional_f = static_cast(dataResponse.optionalStructValue.Value().f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_fClassName.c_str(), OptionalStructValueInsideOptional_fCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_f, OptionalStructValueInsideOptional_f); - jobject OptionalStructValueInsideOptional_g; - std::string OptionalStructValueInsideOptional_gClassName = "java/lang/Float"; - std::string OptionalStructValueInsideOptional_gCtorSignature = "(F)V"; - jfloat jniOptionalStructValueInsideOptional_g = static_cast(dataResponse.optionalStructValue.Value().g); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_gClassName.c_str(), OptionalStructValueInsideOptional_gCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_g, OptionalStructValueInsideOptional_g); - jobject OptionalStructValueInsideOptional_h; - std::string OptionalStructValueInsideOptional_hClassName = "java/lang/Double"; - std::string OptionalStructValueInsideOptional_hCtorSignature = "(D)V"; - jdouble jniOptionalStructValueInsideOptional_h = static_cast(dataResponse.optionalStructValue.Value().h); - chip::JniReferences::GetInstance().CreateBoxedObject( - OptionalStructValueInsideOptional_hClassName.c_str(), OptionalStructValueInsideOptional_hCtorSignature.c_str(), - jniOptionalStructValueInsideOptional_h, OptionalStructValueInsideOptional_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - OptionalStructValueInsideOptional = env->NewObject( - simpleStructStructClass_1, simpleStructStructCtor_1, OptionalStructValueInsideOptional_a, - OptionalStructValueInsideOptional_b, OptionalStructValueInsideOptional_c, OptionalStructValueInsideOptional_d, - OptionalStructValueInsideOptional_e, OptionalStructValueInsideOptional_f, OptionalStructValueInsideOptional_g, - OptionalStructValueInsideOptional_h); - chip::JniReferences::GetInstance().CreateOptional(OptionalStructValueInsideOptional, OptionalStructValue); - } - jobject NullableOptionalStructWasPresent; - std::string NullableOptionalStructWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalStructWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStructWasPresent = static_cast(dataResponse.nullableOptionalStructWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructWasPresentClassName.c_str(), NullableOptionalStructWasPresentCtorSignature.c_str(), - jniNullableOptionalStructWasPresent, NullableOptionalStructWasPresent); - jobject NullableOptionalStructWasNull; - if (!dataResponse.nullableOptionalStructWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStructWasNull); - } - else - { - jobject NullableOptionalStructWasNullInsideOptional; - std::string NullableOptionalStructWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalStructWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStructWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalStructWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructWasNullInsideOptionalClassName.c_str(), - NullableOptionalStructWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalStructWasNullInsideOptional, - NullableOptionalStructWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStructWasNullInsideOptional, - NullableOptionalStructWasNull); - } - jobject NullableOptionalStructValue; - if (!dataResponse.nullableOptionalStructValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStructValue); - } - else - { - jobject NullableOptionalStructValueInsideOptional; - jobject NullableOptionalStructValueInsideOptional_a; - std::string NullableOptionalStructValueInsideOptional_aClassName = "java/lang/Integer"; - std::string NullableOptionalStructValueInsideOptional_aCtorSignature = "(I)V"; - jint jniNullableOptionalStructValueInsideOptional_a = static_cast(dataResponse.nullableOptionalStructValue.Value().a); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalStructValueInsideOptional_aClassName.c_str(), - NullableOptionalStructValueInsideOptional_aCtorSignature.c_str(), - jniNullableOptionalStructValueInsideOptional_a, - NullableOptionalStructValueInsideOptional_a); - jobject NullableOptionalStructValueInsideOptional_b; - std::string NullableOptionalStructValueInsideOptional_bClassName = "java/lang/Boolean"; - std::string NullableOptionalStructValueInsideOptional_bCtorSignature = "(Z)V"; - jboolean jniNullableOptionalStructValueInsideOptional_b = - static_cast(dataResponse.nullableOptionalStructValue.Value().b); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructValueInsideOptional_bClassName.c_str(), - NullableOptionalStructValueInsideOptional_bCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_b, - NullableOptionalStructValueInsideOptional_b); - jobject NullableOptionalStructValueInsideOptional_c; - std::string NullableOptionalStructValueInsideOptional_cClassName = "java/lang/Integer"; - std::string NullableOptionalStructValueInsideOptional_cCtorSignature = "(I)V"; - jint jniNullableOptionalStructValueInsideOptional_c = static_cast(dataResponse.nullableOptionalStructValue.Value().c); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalStructValueInsideOptional_cClassName.c_str(), - NullableOptionalStructValueInsideOptional_cCtorSignature.c_str(), - jniNullableOptionalStructValueInsideOptional_c, - NullableOptionalStructValueInsideOptional_c); - jobject NullableOptionalStructValueInsideOptional_d; - jbyteArray NullableOptionalStructValueInsideOptional_dByteArray = - env->NewByteArray(static_cast(dataResponse.nullableOptionalStructValue.Value().d.size())); - env->SetByteArrayRegion(NullableOptionalStructValueInsideOptional_dByteArray, 0, - static_cast(dataResponse.nullableOptionalStructValue.Value().d.size()), - reinterpret_cast(dataResponse.nullableOptionalStructValue.Value().d.data())); - NullableOptionalStructValueInsideOptional_d = NullableOptionalStructValueInsideOptional_dByteArray; - jobject NullableOptionalStructValueInsideOptional_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStructValue.Value().e, - NullableOptionalStructValueInsideOptional_e)); - jobject NullableOptionalStructValueInsideOptional_f; - std::string NullableOptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; - std::string NullableOptionalStructValueInsideOptional_fCtorSignature = "(I)V"; - jint jniNullableOptionalStructValueInsideOptional_f = - static_cast(dataResponse.nullableOptionalStructValue.Value().f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableOptionalStructValueInsideOptional_fClassName.c_str(), - NullableOptionalStructValueInsideOptional_fCtorSignature.c_str(), - jniNullableOptionalStructValueInsideOptional_f, - NullableOptionalStructValueInsideOptional_f); - jobject NullableOptionalStructValueInsideOptional_g; - std::string NullableOptionalStructValueInsideOptional_gClassName = "java/lang/Float"; - std::string NullableOptionalStructValueInsideOptional_gCtorSignature = "(F)V"; - jfloat jniNullableOptionalStructValueInsideOptional_g = - static_cast(dataResponse.nullableOptionalStructValue.Value().g); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructValueInsideOptional_gClassName.c_str(), - NullableOptionalStructValueInsideOptional_gCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_g, - NullableOptionalStructValueInsideOptional_g); - jobject NullableOptionalStructValueInsideOptional_h; - std::string NullableOptionalStructValueInsideOptional_hClassName = "java/lang/Double"; - std::string NullableOptionalStructValueInsideOptional_hCtorSignature = "(D)V"; - jdouble jniNullableOptionalStructValueInsideOptional_h = - static_cast(dataResponse.nullableOptionalStructValue.Value().h); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalStructValueInsideOptional_hClassName.c_str(), - NullableOptionalStructValueInsideOptional_hCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_h, - NullableOptionalStructValueInsideOptional_h); - - jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_1; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" - "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_1); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - NullableOptionalStructValueInsideOptional = - env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, NullableOptionalStructValueInsideOptional_a, - NullableOptionalStructValueInsideOptional_b, NullableOptionalStructValueInsideOptional_c, - NullableOptionalStructValueInsideOptional_d, NullableOptionalStructValueInsideOptional_e, - NullableOptionalStructValueInsideOptional_f, NullableOptionalStructValueInsideOptional_g, - NullableOptionalStructValueInsideOptional_h); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStructValueInsideOptional, NullableOptionalStructValue); - } - jobject NullableListWasNull; - std::string NullableListWasNullClassName = "java/lang/Boolean"; - std::string NullableListWasNullCtorSignature = "(Z)V"; - jboolean jniNullableListWasNull = static_cast(dataResponse.nullableListWasNull); - chip::JniReferences::GetInstance().CreateBoxedObject(NullableListWasNullClassName.c_str(), - NullableListWasNullCtorSignature.c_str(), jniNullableListWasNull, - NullableListWasNull); - jobject NullableListValue; - if (!dataResponse.nullableListValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableListValue); - } - else - { - jobject NullableListValueInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(NullableListValueInsideOptional); - - auto iter_NullableListValueInsideOptional_1 = dataResponse.nullableListValue.Value().begin(); - while (iter_NullableListValueInsideOptional_1.Next()) - { - auto & entry_1 = iter_NullableListValueInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(NullableListValueInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(NullableListValueInsideOptional, NullableListValue); - } - jobject OptionalListWasPresent; - std::string OptionalListWasPresentClassName = "java/lang/Boolean"; - std::string OptionalListWasPresentCtorSignature = "(Z)V"; - jboolean jniOptionalListWasPresent = static_cast(dataResponse.optionalListWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject(OptionalListWasPresentClassName.c_str(), - OptionalListWasPresentCtorSignature.c_str(), - jniOptionalListWasPresent, OptionalListWasPresent); - jobject OptionalListValue; - if (!dataResponse.optionalListValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalListValue); - } - else - { - jobject OptionalListValueInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(OptionalListValueInsideOptional); - - auto iter_OptionalListValueInsideOptional_1 = dataResponse.optionalListValue.Value().begin(); - while (iter_OptionalListValueInsideOptional_1.Next()) - { - auto & entry_1 = iter_OptionalListValueInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(OptionalListValueInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(OptionalListValueInsideOptional, OptionalListValue); - } - jobject NullableOptionalListWasPresent; - std::string NullableOptionalListWasPresentClassName = "java/lang/Boolean"; - std::string NullableOptionalListWasPresentCtorSignature = "(Z)V"; - jboolean jniNullableOptionalListWasPresent = static_cast(dataResponse.nullableOptionalListWasPresent); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalListWasPresentClassName.c_str(), NullableOptionalListWasPresentCtorSignature.c_str(), - jniNullableOptionalListWasPresent, NullableOptionalListWasPresent); - jobject NullableOptionalListWasNull; - if (!dataResponse.nullableOptionalListWasNull.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalListWasNull); - } - else - { - jobject NullableOptionalListWasNullInsideOptional; - std::string NullableOptionalListWasNullInsideOptionalClassName = "java/lang/Boolean"; - std::string NullableOptionalListWasNullInsideOptionalCtorSignature = "(Z)V"; - jboolean jniNullableOptionalListWasNullInsideOptional = - static_cast(dataResponse.nullableOptionalListWasNull.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject( - NullableOptionalListWasNullInsideOptionalClassName.c_str(), - NullableOptionalListWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalListWasNullInsideOptional, - NullableOptionalListWasNullInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalListWasNullInsideOptional, NullableOptionalListWasNull); - } - jobject NullableOptionalListValue; - if (!dataResponse.nullableOptionalListValue.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalListValue); - } - else - { - jobject NullableOptionalListValueInsideOptional; - chip::JniReferences::GetInstance().CreateArrayList(NullableOptionalListValueInsideOptional); - - auto iter_NullableOptionalListValueInsideOptional_1 = dataResponse.nullableOptionalListValue.Value().begin(); - while (iter_NullableOptionalListValueInsideOptional_1.Next()) - { - auto & entry_1 = iter_NullableOptionalListValueInsideOptional_1.GetValue(); - jobject newElement_1; - std::string newElement_1ClassName = "java/lang/Integer"; - std::string newElement_1CtorSignature = "(I)V"; - jint jninewElement_1 = static_cast(entry_1); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); - chip::JniReferences::GetInstance().AddToList(NullableOptionalListValueInsideOptional, newElement_1); - } - chip::JniReferences::GetInstance().CreateOptional(NullableOptionalListValueInsideOptional, NullableOptionalListValue); - } - - env->CallVoidMethod(javaCallbackRef, javaMethod, NullableIntWasNull, NullableIntValue, OptionalIntWasPresent, OptionalIntValue, - NullableOptionalIntWasPresent, NullableOptionalIntWasNull, NullableOptionalIntValue, NullableStringWasNull, - NullableStringValue, OptionalStringWasPresent, OptionalStringValue, NullableOptionalStringWasPresent, - NullableOptionalStringWasNull, NullableOptionalStringValue, NullableStructWasNull, NullableStructValue, - OptionalStructWasPresent, OptionalStructValue, NullableOptionalStructWasPresent, - NullableOptionalStructWasNull, NullableOptionalStructValue, NullableListWasNull, NullableListValue, - OptionalListWasPresent, OptionalListValue, NullableOptionalListWasPresent, NullableOptionalListWasNull, - NullableOptionalListValue); -} -CHIPUnitTestingClusterBooleanResponseCallback::CHIPUnitTestingClusterBooleanResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterBooleanResponseCallback::~CHIPUnitTestingClusterBooleanResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterBooleanResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject value; - std::string valueClassName = "java/lang/Boolean"; - std::string valueCtorSignature = "(Z)V"; - jboolean jnivalue = static_cast(dataResponse.value); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - - env->CallVoidMethod(javaCallbackRef, javaMethod, value); -} -CHIPUnitTestingClusterSimpleStructResponseCallback::CHIPUnitTestingClusterSimpleStructResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterSimpleStructResponseCallback::~CHIPUnitTestingClusterSimpleStructResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterSimpleStructResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod( - env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - jobject arg1_a; - std::string arg1_aClassName = "java/lang/Integer"; - std::string arg1_aCtorSignature = "(I)V"; - jint jniarg1_a = static_cast(dataResponse.arg1.a); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_aClassName.c_str(), arg1_aCtorSignature.c_str(), jniarg1_a, - arg1_a); - jobject arg1_b; - std::string arg1_bClassName = "java/lang/Boolean"; - std::string arg1_bCtorSignature = "(Z)V"; - jboolean jniarg1_b = static_cast(dataResponse.arg1.b); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_bClassName.c_str(), arg1_bCtorSignature.c_str(), jniarg1_b, - arg1_b); - jobject arg1_c; - std::string arg1_cClassName = "java/lang/Integer"; - std::string arg1_cCtorSignature = "(I)V"; - jint jniarg1_c = static_cast(dataResponse.arg1.c); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_cClassName.c_str(), arg1_cCtorSignature.c_str(), jniarg1_c, - arg1_c); - jobject arg1_d; - jbyteArray arg1_dByteArray = env->NewByteArray(static_cast(dataResponse.arg1.d.size())); - env->SetByteArrayRegion(arg1_dByteArray, 0, static_cast(dataResponse.arg1.d.size()), - reinterpret_cast(dataResponse.arg1.d.data())); - arg1_d = arg1_dByteArray; - jobject arg1_e; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.arg1.e, arg1_e)); - jobject arg1_f; - std::string arg1_fClassName = "java/lang/Integer"; - std::string arg1_fCtorSignature = "(I)V"; - jint jniarg1_f = static_cast(dataResponse.arg1.f.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_fClassName.c_str(), arg1_fCtorSignature.c_str(), jniarg1_f, - arg1_f); - jobject arg1_g; - std::string arg1_gClassName = "java/lang/Float"; - std::string arg1_gCtorSignature = "(F)V"; - jfloat jniarg1_g = static_cast(dataResponse.arg1.g); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_gClassName.c_str(), arg1_gCtorSignature.c_str(), jniarg1_g, - arg1_g); - jobject arg1_h; - std::string arg1_hClassName = "java/lang/Double"; - std::string arg1_hCtorSignature = "(D)V"; - jdouble jniarg1_h = static_cast(dataResponse.arg1.h); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1_hClassName.c_str(), arg1_hCtorSignature.c_str(), jniarg1_h, - arg1_h); - - jclass simpleStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", - simpleStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); - return; - } - - jmethodID simpleStructStructCtor_0; - err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_0, "", - "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/" - "String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", - &simpleStructStructCtor_0); - if (err != CHIP_NO_ERROR || simpleStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); - return; - } - - arg1 = env->NewObject(simpleStructStructClass_0, simpleStructStructCtor_0, arg1_a, arg1_b, arg1_c, arg1_d, arg1_e, arg1_f, - arg1_g, arg1_h); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1); -} -CHIPUnitTestingClusterTestEmitTestEventResponseCallback::CHIPUnitTestingClusterTestEmitTestEventResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestEmitTestEventResponseCallback::~CHIPUnitTestingClusterTestEmitTestEventResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestEmitTestEventResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(dataResponse.value); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - - env->CallVoidMethod(javaCallbackRef, javaMethod, value); -} -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback:: -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback::~ -CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback::CallbackFn( - void * context, - const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(dataResponse.value); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - - env->CallVoidMethod(javaCallbackRef, javaMethod, value); -} -CHIPUnitTestingClusterTestBatchHelperResponseCallback::CHIPUnitTestingClusterTestBatchHelperResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestBatchHelperResponseCallback::~CHIPUnitTestingClusterTestBatchHelperResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestBatchHelperResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject buffer; - jbyteArray bufferByteArray = env->NewByteArray(static_cast(dataResponse.buffer.size())); - env->SetByteArrayRegion(bufferByteArray, 0, static_cast(dataResponse.buffer.size()), - reinterpret_cast(dataResponse.buffer.data())); - buffer = bufferByteArray; - - env->CallVoidMethod(javaCallbackRef, javaMethod, buffer); -} -CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback::CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback( - jobject javaCallback) : Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback::~CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPUnitTestingClusterTestDifferentVendorMeiResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::UnitTesting::Commands::TestDifferentVendorMeiResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Long;)V", - &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject arg1; - std::string arg1ClassName = "java/lang/Integer"; - std::string arg1CtorSignature = "(I)V"; - jint jniarg1 = static_cast(dataResponse.arg1); - chip::JniReferences::GetInstance().CreateBoxedObject(arg1ClassName.c_str(), arg1CtorSignature.c_str(), jniarg1, arg1); - jobject eventNumber; - std::string eventNumberClassName = "java/lang/Long"; - std::string eventNumberCtorSignature = "(J)V"; - jlong jnieventNumber = static_cast(dataResponse.eventNumber); - chip::JniReferences::GetInstance().CreateBoxedObject(eventNumberClassName.c_str(), eventNumberCtorSignature.c_str(), - jnieventNumber, eventNumber); - - env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, eventNumber); -} -CHIPSampleMeiClusterAddArgumentsResponseCallback::CHIPSampleMeiClusterAddArgumentsResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPSampleMeiClusterAddArgumentsResponseCallback::~CHIPSampleMeiClusterAddArgumentsResponseCallback() -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -}; - -void CHIPSampleMeiClusterAddArgumentsResponseCallback::CallbackFn( - void * context, const chip::app::Clusters::SampleMei::Commands::AddArgumentsResponse::DecodableType & dataResponse) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - jmethodID javaMethod; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); - - std::unique_ptr - cppCallback(reinterpret_cast(context), - chip::Platform::Delete); - VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); - - javaCallbackRef = cppCallback->javaCallbackRef; - // Java callback is allowed to be null, exit early if this is the case. - VerifyOrReturn(javaCallbackRef != nullptr); - - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); - - jobject returnValue; - std::string returnValueClassName = "java/lang/Integer"; - std::string returnValueCtorSignature = "(I)V"; - jint jnireturnValue = static_cast(dataResponse.returnValue); - chip::JniReferences::GetInstance().CreateBoxedObject(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), - jnireturnValue, returnValue); - - env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); -} -} // namespace chip diff --git a/src/credentials/BUILD.gn b/src/credentials/BUILD.gn index cd12f485e32009..dc5b7163be92e3 100644 --- a/src/credentials/BUILD.gn +++ b/src/credentials/BUILD.gn @@ -63,7 +63,9 @@ static_library("credentials") { "CHIPCert.h", "CHIPCertFromX509.cpp", "CHIPCertToX509.cpp", + "CHIPCert_Internal.h", "CHIPCertificateSet.h", + "CertificateValidityPolicy.h", "CertificationDeclaration.cpp", "CertificationDeclaration.h", "DeviceAttestationConstructor.cpp", @@ -76,6 +78,7 @@ static_library("credentials") { "GenerateChipX509Cert.cpp", "GroupDataProvider.h", "GroupDataProviderImpl.cpp", + "GroupDataProviderImpl.h", "LastKnownGoodTime.cpp", "LastKnownGoodTime.h", "OperationalCertificateStore.h", diff --git a/src/darwin/Framework/CHIP/MTRClusterNames.h b/src/darwin/Framework/CHIP/MTRClusterNames.h new file mode 100644 index 00000000000000..f4134205228d90 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRClusterNames.h @@ -0,0 +1,43 @@ +/* + * + * 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 + +#import +#import + +/** + * This file defines functions to resolve Matter cluster and attribute IDs into + * strings. + */ + +/** + * Resolve Matter cluster IDs into a descriptive string. + * + * For unknown IDs, a string '' will be returned. + */ +MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRClusterNameForID(MTRClusterIDType clusterID); + +/** + * Resolve Matter attribute IDs into a descriptive string. + * + * For unknown IDs, a string '' (if the cluster ID is not known) + * or '' (if the cluster ID is known but the attribute ID is not known) + * will be returned. + */ +MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID); diff --git a/src/darwin/Framework/CHIP/Matter.h b/src/darwin/Framework/CHIP/Matter.h index 37b72902281b1c..ebbe1b3765917c 100644 --- a/src/darwin/Framework/CHIP/Matter.h +++ b/src/darwin/Framework/CHIP/Matter.h @@ -29,6 +29,7 @@ #import #import #import +#import #import #import #import diff --git a/src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt new file mode 100644 index 00000000000000..b495d79b1b4c72 --- /dev/null +++ b/src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt @@ -0,0 +1,89 @@ +{{> header excludeZapComment=true}} + + +#import + +// @implementation MTRClusterAttributeIDType + +#pragma mark - Clusters IDs + +NSString * MTRClusterNameForID(MTRClusterIDType clusterID) +{ + NSString * result = nil; + + switch (clusterID) { + +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} + case MTRClusterIDType{{>cluster}}ID: + result = @"{{>cluster}}"; + break; +{{/if}} +{{/zcl_clusters}} + + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + + +#pragma mark - Attributes IDs + +NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID) +{ + NSString * result = nil; + + switch (clusterID) { + +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} + case MTRClusterIDType{{>cluster}}ID: + + switch (attributeID) { + +{{/if}} + +{{#*inline "attributeIDs"}} +{{#zcl_attributes_server}} +{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} +{{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} +{{#first}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}} +// Cluster {{> cluster}} attributes +{{/if}} +{{/first}} +{{#if (and (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true) + (or clusterRef + (isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)))}} + case MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID: + result = @"{{>attribute}}"; + break; + +{{/if}} +{{/zcl_attributes_server}} +{{/inline}} + +{{> attributeIDs clusterName=label}} + +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } +{{/if}} + +{{/zcl_clusters}} + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + +// @end diff --git a/src/darwin/Framework/CHIP/templates/templates.json b/src/darwin/Framework/CHIP/templates/templates.json index 59a06b83c2fd99..83df8bdab40e63 100644 --- a/src/darwin/Framework/CHIP/templates/templates.json +++ b/src/darwin/Framework/CHIP/templates/templates.json @@ -120,6 +120,11 @@ "name": "Constants for cluster IDs", "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h" }, + { + "path": "MTRClusterNames-src.zapt", + "name": "Objc Cluster Names API", + "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm" + }, { "path": "MTRAttributeSpecifiedCheck-src.zapt", "name": "Function to check if attribute is specified", diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm new file mode 100644 index 00000000000000..8cbf42f6dda47e --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm @@ -0,0 +1,8772 @@ +/* + * + * Copyright (c) 2022 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. + */ + +#import + +// @implementation MTRClusterAttributeIDType + +#pragma mark - Clusters IDs + +NSString * MTRClusterNameForID(MTRClusterIDType clusterID) +{ + NSString * result = nil; + + switch (clusterID) { + + case MTRClusterIDTypeIdentifyID: + result = @"Identify"; + break; + case MTRClusterIDTypeGroupsID: + result = @"Groups"; + break; + case MTRClusterIDTypeOnOffID: + result = @"OnOff"; + break; + case MTRClusterIDTypeOnOffSwitchConfigurationID: + result = @"OnOffSwitchConfiguration"; + break; + case MTRClusterIDTypeLevelControlID: + result = @"LevelControl"; + break; + case MTRClusterIDTypeBinaryInputBasicID: + result = @"BinaryInputBasic"; + break; + case MTRClusterIDTypePulseWidthModulationID: + result = @"PulseWidthModulation"; + break; + case MTRClusterIDTypeDescriptorID: + result = @"Descriptor"; + break; + case MTRClusterIDTypeBindingID: + result = @"Binding"; + break; + case MTRClusterIDTypeAccessControlID: + result = @"AccessControl"; + break; + case MTRClusterIDTypeActionsID: + result = @"Actions"; + break; + case MTRClusterIDTypeBasicInformationID: + result = @"BasicInformation"; + break; + case MTRClusterIDTypeOTASoftwareUpdateProviderID: + result = @"OTASoftwareUpdateProvider"; + break; + case MTRClusterIDTypeOTASoftwareUpdateRequestorID: + result = @"OTASoftwareUpdateRequestor"; + break; + case MTRClusterIDTypeLocalizationConfigurationID: + result = @"LocalizationConfiguration"; + break; + case MTRClusterIDTypeTimeFormatLocalizationID: + result = @"TimeFormatLocalization"; + break; + case MTRClusterIDTypeUnitLocalizationID: + result = @"UnitLocalization"; + break; + case MTRClusterIDTypePowerSourceConfigurationID: + result = @"PowerSourceConfiguration"; + break; + case MTRClusterIDTypePowerSourceID: + result = @"PowerSource"; + break; + case MTRClusterIDTypeGeneralCommissioningID: + result = @"GeneralCommissioning"; + break; + case MTRClusterIDTypeNetworkCommissioningID: + result = @"NetworkCommissioning"; + break; + case MTRClusterIDTypeDiagnosticLogsID: + result = @"DiagnosticLogs"; + break; + case MTRClusterIDTypeGeneralDiagnosticsID: + result = @"GeneralDiagnostics"; + break; + case MTRClusterIDTypeSoftwareDiagnosticsID: + result = @"SoftwareDiagnostics"; + break; + case MTRClusterIDTypeThreadNetworkDiagnosticsID: + result = @"ThreadNetworkDiagnostics"; + break; + case MTRClusterIDTypeWiFiNetworkDiagnosticsID: + result = @"WiFiNetworkDiagnostics"; + break; + case MTRClusterIDTypeEthernetNetworkDiagnosticsID: + result = @"EthernetNetworkDiagnostics"; + break; + case MTRClusterIDTypeTimeSynchronizationID: + result = @"TimeSynchronization"; + break; + case MTRClusterIDTypeBridgedDeviceBasicInformationID: + result = @"BridgedDeviceBasicInformation"; + break; + case MTRClusterIDTypeSwitchID: + result = @"Switch"; + break; + case MTRClusterIDTypeAdministratorCommissioningID: + result = @"AdministratorCommissioning"; + break; + case MTRClusterIDTypeOperationalCredentialsID: + result = @"OperationalCredentials"; + break; + case MTRClusterIDTypeGroupKeyManagementID: + result = @"GroupKeyManagement"; + break; + case MTRClusterIDTypeFixedLabelID: + result = @"FixedLabel"; + break; + case MTRClusterIDTypeUserLabelID: + result = @"UserLabel"; + break; + case MTRClusterIDTypeBooleanStateID: + result = @"BooleanState"; + break; + case MTRClusterIDTypeICDManagementID: + result = @"ICDManagement"; + break; + case MTRClusterIDTypeTimerID: + result = @"Timer"; + break; + case MTRClusterIDTypeOvenCavityOperationalStateID: + result = @"OvenCavityOperationalState"; + break; + case MTRClusterIDTypeOvenModeID: + result = @"OvenMode"; + break; + case MTRClusterIDTypeLaundryDryerControlsID: + result = @"LaundryDryerControls"; + break; + case MTRClusterIDTypeModeSelectID: + result = @"ModeSelect"; + break; + case MTRClusterIDTypeLaundryWasherModeID: + result = @"LaundryWasherMode"; + break; + case MTRClusterIDTypeRefrigeratorAndTemperatureControlledCabinetModeID: + result = @"RefrigeratorAndTemperatureControlledCabinetMode"; + break; + case MTRClusterIDTypeLaundryWasherControlsID: + result = @"LaundryWasherControls"; + break; + case MTRClusterIDTypeRVCRunModeID: + result = @"RVCRunMode"; + break; + case MTRClusterIDTypeRVCCleanModeID: + result = @"RVCCleanMode"; + break; + case MTRClusterIDTypeTemperatureControlID: + result = @"TemperatureControl"; + break; + case MTRClusterIDTypeRefrigeratorAlarmID: + result = @"RefrigeratorAlarm"; + break; + case MTRClusterIDTypeDishwasherModeID: + result = @"DishwasherMode"; + break; + case MTRClusterIDTypeAirQualityID: + result = @"AirQuality"; + break; + case MTRClusterIDTypeSmokeCOAlarmID: + result = @"SmokeCOAlarm"; + break; + case MTRClusterIDTypeDishwasherAlarmID: + result = @"DishwasherAlarm"; + break; + case MTRClusterIDTypeMicrowaveOvenModeID: + result = @"MicrowaveOvenMode"; + break; + case MTRClusterIDTypeMicrowaveOvenControlID: + result = @"MicrowaveOvenControl"; + break; + case MTRClusterIDTypeOperationalStateID: + result = @"OperationalState"; + break; + case MTRClusterIDTypeRVCOperationalStateID: + result = @"RVCOperationalState"; + break; + case MTRClusterIDTypeScenesManagementID: + result = @"ScenesManagement"; + break; + case MTRClusterIDTypeHEPAFilterMonitoringID: + result = @"HEPAFilterMonitoring"; + break; + case MTRClusterIDTypeActivatedCarbonFilterMonitoringID: + result = @"ActivatedCarbonFilterMonitoring"; + break; + case MTRClusterIDTypeBooleanStateConfigurationID: + result = @"BooleanStateConfiguration"; + break; + case MTRClusterIDTypeValveConfigurationAndControlID: + result = @"ValveConfigurationAndControl"; + break; + case MTRClusterIDTypeElectricalPowerMeasurementID: + result = @"ElectricalPowerMeasurement"; + break; + case MTRClusterIDTypeElectricalEnergyMeasurementID: + result = @"ElectricalEnergyMeasurement"; + break; + case MTRClusterIDTypeDemandResponseLoadControlID: + result = @"DemandResponseLoadControl"; + break; + case MTRClusterIDTypeMessagesID: + result = @"Messages"; + break; + case MTRClusterIDTypeDeviceEnergyManagementID: + result = @"DeviceEnergyManagement"; + break; + case MTRClusterIDTypeEnergyEVSEID: + result = @"EnergyEVSE"; + break; + case MTRClusterIDTypeEnergyPreferenceID: + result = @"EnergyPreference"; + break; + case MTRClusterIDTypeEnergyEVSEModeID: + result = @"EnergyEVSEMode"; + break; + case MTRClusterIDTypeDeviceEnergyManagementModeID: + result = @"DeviceEnergyManagementMode"; + break; + case MTRClusterIDTypeDoorLockID: + result = @"DoorLock"; + break; + case MTRClusterIDTypeWindowCoveringID: + result = @"WindowCovering"; + break; + case MTRClusterIDTypeBarrierControlID: + result = @"BarrierControl"; + break; + case MTRClusterIDTypePumpConfigurationAndControlID: + result = @"PumpConfigurationAndControl"; + break; + case MTRClusterIDTypeThermostatID: + result = @"Thermostat"; + break; + case MTRClusterIDTypeFanControlID: + result = @"FanControl"; + break; + case MTRClusterIDTypeThermostatUserInterfaceConfigurationID: + result = @"ThermostatUserInterfaceConfiguration"; + break; + case MTRClusterIDTypeColorControlID: + result = @"ColorControl"; + break; + case MTRClusterIDTypeBallastConfigurationID: + result = @"BallastConfiguration"; + break; + case MTRClusterIDTypeIlluminanceMeasurementID: + result = @"IlluminanceMeasurement"; + break; + case MTRClusterIDTypeTemperatureMeasurementID: + result = @"TemperatureMeasurement"; + break; + case MTRClusterIDTypePressureMeasurementID: + result = @"PressureMeasurement"; + break; + case MTRClusterIDTypeFlowMeasurementID: + result = @"FlowMeasurement"; + break; + case MTRClusterIDTypeRelativeHumidityMeasurementID: + result = @"RelativeHumidityMeasurement"; + break; + case MTRClusterIDTypeOccupancySensingID: + result = @"OccupancySensing"; + break; + case MTRClusterIDTypeCarbonMonoxideConcentrationMeasurementID: + result = @"CarbonMonoxideConcentrationMeasurement"; + break; + case MTRClusterIDTypeCarbonDioxideConcentrationMeasurementID: + result = @"CarbonDioxideConcentrationMeasurement"; + break; + case MTRClusterIDTypeNitrogenDioxideConcentrationMeasurementID: + result = @"NitrogenDioxideConcentrationMeasurement"; + break; + case MTRClusterIDTypeOzoneConcentrationMeasurementID: + result = @"OzoneConcentrationMeasurement"; + break; + case MTRClusterIDTypePM25ConcentrationMeasurementID: + result = @"PM25ConcentrationMeasurement"; + break; + case MTRClusterIDTypeFormaldehydeConcentrationMeasurementID: + result = @"FormaldehydeConcentrationMeasurement"; + break; + case MTRClusterIDTypePM1ConcentrationMeasurementID: + result = @"PM1ConcentrationMeasurement"; + break; + case MTRClusterIDTypePM10ConcentrationMeasurementID: + result = @"PM10ConcentrationMeasurement"; + break; + case MTRClusterIDTypeTotalVolatileOrganicCompoundsConcentrationMeasurementID: + result = @"TotalVolatileOrganicCompoundsConcentrationMeasurement"; + break; + case MTRClusterIDTypeRadonConcentrationMeasurementID: + result = @"RadonConcentrationMeasurement"; + break; + case MTRClusterIDTypeWakeOnLANID: + result = @"WakeOnLAN"; + break; + case MTRClusterIDTypeChannelID: + result = @"Channel"; + break; + case MTRClusterIDTypeTargetNavigatorID: + result = @"TargetNavigator"; + break; + case MTRClusterIDTypeMediaPlaybackID: + result = @"MediaPlayback"; + break; + case MTRClusterIDTypeMediaInputID: + result = @"MediaInput"; + break; + case MTRClusterIDTypeLowPowerID: + result = @"LowPower"; + break; + case MTRClusterIDTypeKeypadInputID: + result = @"KeypadInput"; + break; + case MTRClusterIDTypeContentLauncherID: + result = @"ContentLauncher"; + break; + case MTRClusterIDTypeAudioOutputID: + result = @"AudioOutput"; + break; + case MTRClusterIDTypeApplicationLauncherID: + result = @"ApplicationLauncher"; + break; + case MTRClusterIDTypeApplicationBasicID: + result = @"ApplicationBasic"; + break; + case MTRClusterIDTypeAccountLoginID: + result = @"AccountLogin"; + break; + case MTRClusterIDTypeContentControlID: + result = @"ContentControl"; + break; + case MTRClusterIDTypeContentAppObserverID: + result = @"ContentAppObserver"; + break; + case MTRClusterIDTypeElectricalMeasurementID: + result = @"ElectricalMeasurement"; + break; + case MTRClusterIDTypeUnitTestingID: + result = @"UnitTesting"; + break; + case MTRClusterIDTypeSampleMEIID: + result = @"SampleMEI"; + break; + + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + +#pragma mark - Attributes IDs + +NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID) +{ + NSString * result = nil; + + switch (clusterID) { + + case MTRClusterIDTypeIdentifyID: + + switch (attributeID) { + + // Cluster Identify attributes + case MTRAttributeIDTypeClusterIdentifyAttributeIdentifyTimeID: + result = @"IdentifyTime"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeIdentifyTypeID: + result = @"IdentifyType"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterIdentifyAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGroupsID: + + switch (attributeID) { + + // Cluster Groups attributes + case MTRAttributeIDTypeClusterGroupsAttributeNameSupportID: + result = @"NameSupport"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGroupsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOnOffID: + + switch (attributeID) { + + // Cluster OnOff attributes + case MTRAttributeIDTypeClusterOnOffAttributeOnOffID: + result = @"OnOff"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeGlobalSceneControlID: + result = @"GlobalSceneControl"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeOnTimeID: + result = @"OnTime"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeOffWaitTimeID: + result = @"OffWaitTime"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeStartUpOnOffID: + result = @"StartUpOnOff"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOnOffAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOnOffSwitchConfigurationID: + + switch (attributeID) { + + // Cluster OnOffSwitchConfiguration attributes + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeSwitchTypeID: + result = @"SwitchType"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeSwitchActionsID: + result = @"SwitchActions"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOnOffSwitchConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLevelControlID: + + switch (attributeID) { + + // Cluster LevelControl attributes + case MTRAttributeIDTypeClusterLevelControlAttributeCurrentLevelID: + result = @"CurrentLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeRemainingTimeID: + result = @"RemainingTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMinLevelID: + result = @"MinLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMaxLevelID: + result = @"MaxLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeCurrentFrequencyID: + result = @"CurrentFrequency"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMinFrequencyID: + result = @"MinFrequency"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeMaxFrequencyID: + result = @"MaxFrequency"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOptionsID: + result = @"Options"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOnOffTransitionTimeID: + result = @"OnOffTransitionTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOnLevelID: + result = @"OnLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOnTransitionTimeID: + result = @"OnTransitionTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeOffTransitionTimeID: + result = @"OffTransitionTime"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeDefaultMoveRateID: + result = @"DefaultMoveRate"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeStartUpCurrentLevelID: + result = @"StartUpCurrentLevel"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLevelControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBinaryInputBasicID: + + switch (attributeID) { + + // Cluster BinaryInputBasic attributes + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeActiveTextID: + result = @"ActiveText"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeDescriptionID: + result = @"Description"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeInactiveTextID: + result = @"InactiveText"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeOutOfServiceID: + result = @"OutOfService"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributePolarityID: + result = @"Polarity"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributePresentValueID: + result = @"PresentValue"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeReliabilityID: + result = @"Reliability"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeStatusFlagsID: + result = @"StatusFlags"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeApplicationTypeID: + result = @"ApplicationType"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBinaryInputBasicAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePulseWidthModulationID: + + switch (attributeID) { + + // Cluster PulseWidthModulation attributes + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPulseWidthModulationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDescriptorID: + + switch (attributeID) { + + // Cluster Descriptor attributes + case MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID: + result = @"DeviceTypeList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeServerListID: + result = @"ServerList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeClientListID: + result = @"ClientList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributePartsListID: + result = @"PartsList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeTagListID: + result = @"TagList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDescriptorAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBindingID: + + switch (attributeID) { + + // Cluster Binding attributes + case MTRAttributeIDTypeClusterBindingAttributeBindingID: + result = @"Binding"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBindingAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAccessControlID: + + switch (attributeID) { + + // Cluster AccessControl attributes + case MTRAttributeIDTypeClusterAccessControlAttributeACLID: + result = @"ACL"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeExtensionID: + result = @"Extension"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeSubjectsPerAccessControlEntryID: + result = @"SubjectsPerAccessControlEntry"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeTargetsPerAccessControlEntryID: + result = @"TargetsPerAccessControlEntry"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeAccessControlEntriesPerFabricID: + result = @"AccessControlEntriesPerFabric"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAccessControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeActionsID: + + switch (attributeID) { + + // Cluster Actions attributes + case MTRAttributeIDTypeClusterActionsAttributeActionListID: + result = @"ActionList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeEndpointListsID: + result = @"EndpointLists"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeSetupURLID: + result = @"SetupURL"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterActionsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBasicInformationID: + + switch (attributeID) { + + // Cluster BasicInformation attributes + case MTRAttributeIDTypeClusterBasicInformationAttributeDataModelRevisionID: + result = @"DataModelRevision"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeVendorNameID: + result = @"VendorName"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeVendorIDID: + result = @"VendorID"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductNameID: + result = @"ProductName"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductIDID: + result = @"ProductID"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeNodeLabelID: + result = @"NodeLabel"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeLocationID: + result = @"Location"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeHardwareVersionID: + result = @"HardwareVersion"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeHardwareVersionStringID: + result = @"HardwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSoftwareVersionID: + result = @"SoftwareVersion"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSoftwareVersionStringID: + result = @"SoftwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeManufacturingDateID: + result = @"ManufacturingDate"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributePartNumberID: + result = @"PartNumber"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductURLID: + result = @"ProductURL"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductLabelID: + result = @"ProductLabel"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSerialNumberID: + result = @"SerialNumber"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeLocalConfigDisabledID: + result = @"LocalConfigDisabled"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeReachableID: + result = @"Reachable"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeUniqueIDID: + result = @"UniqueID"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeCapabilityMinimaID: + result = @"CapabilityMinima"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeProductAppearanceID: + result = @"ProductAppearance"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeSpecificationVersionID: + result = @"SpecificationVersion"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeMaxPathsPerInvokeID: + result = @"MaxPathsPerInvoke"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBasicInformationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOTASoftwareUpdateProviderID: + + switch (attributeID) { + + // Cluster OTASoftwareUpdateProvider attributes + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateProviderAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOTASoftwareUpdateRequestorID: + + switch (attributeID) { + + // Cluster OTASoftwareUpdateRequestor attributes + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeDefaultOTAProvidersID: + result = @"DefaultOTAProviders"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeUpdatePossibleID: + result = @"UpdatePossible"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeUpdateStateID: + result = @"UpdateState"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeUpdateStateProgressID: + result = @"UpdateStateProgress"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOTASoftwareUpdateRequestorAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLocalizationConfigurationID: + + switch (attributeID) { + + // Cluster LocalizationConfiguration attributes + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeActiveLocaleID: + result = @"ActiveLocale"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeSupportedLocalesID: + result = @"SupportedLocales"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLocalizationConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTimeFormatLocalizationID: + + switch (attributeID) { + + // Cluster TimeFormatLocalization attributes + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeHourFormatID: + result = @"HourFormat"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeActiveCalendarTypeID: + result = @"ActiveCalendarType"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeSupportedCalendarTypesID: + result = @"SupportedCalendarTypes"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTimeFormatLocalizationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeUnitLocalizationID: + + switch (attributeID) { + + // Cluster UnitLocalization attributes + case MTRAttributeIDTypeClusterUnitLocalizationAttributeTemperatureUnitID: + result = @"TemperatureUnit"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterUnitLocalizationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePowerSourceConfigurationID: + + switch (attributeID) { + + // Cluster PowerSourceConfiguration attributes + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeSourcesID: + result = @"Sources"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPowerSourceConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePowerSourceID: + + switch (attributeID) { + + // Cluster PowerSource attributes + case MTRAttributeIDTypeClusterPowerSourceAttributeStatusID: + result = @"Status"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeOrderID: + result = @"Order"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeDescriptionID: + result = @"Description"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredAssessedInputVoltageID: + result = @"WiredAssessedInputVoltage"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredAssessedInputFrequencyID: + result = @"WiredAssessedInputFrequency"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredCurrentTypeID: + result = @"WiredCurrentType"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredAssessedCurrentID: + result = @"WiredAssessedCurrent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredNominalVoltageID: + result = @"WiredNominalVoltage"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredMaximumCurrentID: + result = @"WiredMaximumCurrent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeWiredPresentID: + result = @"WiredPresent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeActiveWiredFaultsID: + result = @"ActiveWiredFaults"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatVoltageID: + result = @"BatVoltage"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatPercentRemainingID: + result = @"BatPercentRemaining"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatTimeRemainingID: + result = @"BatTimeRemaining"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatChargeLevelID: + result = @"BatChargeLevel"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatReplacementNeededID: + result = @"BatReplacementNeeded"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatReplaceabilityID: + result = @"BatReplaceability"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatPresentID: + result = @"BatPresent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeActiveBatFaultsID: + result = @"ActiveBatFaults"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatReplacementDescriptionID: + result = @"BatReplacementDescription"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatCommonDesignationID: + result = @"BatCommonDesignation"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatANSIDesignationID: + result = @"BatANSIDesignation"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatIECDesignationID: + result = @"BatIECDesignation"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatApprovedChemistryID: + result = @"BatApprovedChemistry"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatCapacityID: + result = @"BatCapacity"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatQuantityID: + result = @"BatQuantity"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatChargeStateID: + result = @"BatChargeState"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatTimeToFullChargeID: + result = @"BatTimeToFullCharge"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatFunctionalWhileChargingID: + result = @"BatFunctionalWhileCharging"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeBatChargingCurrentID: + result = @"BatChargingCurrent"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeActiveBatChargeFaultsID: + result = @"ActiveBatChargeFaults"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeEndpointListID: + result = @"EndpointList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPowerSourceAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGeneralCommissioningID: + + switch (attributeID) { + + // Cluster GeneralCommissioning attributes + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeBreadcrumbID: + result = @"Breadcrumb"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeBasicCommissioningInfoID: + result = @"BasicCommissioningInfo"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeRegulatoryConfigID: + result = @"RegulatoryConfig"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeLocationCapabilityID: + result = @"LocationCapability"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeSupportsConcurrentConnectionID: + result = @"SupportsConcurrentConnection"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGeneralCommissioningAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeNetworkCommissioningID: + + switch (attributeID) { + + // Cluster NetworkCommissioning attributes + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeMaxNetworksID: + result = @"MaxNetworks"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeNetworksID: + result = @"Networks"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeScanMaxTimeSecondsID: + result = @"ScanMaxTimeSeconds"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeConnectMaxTimeSecondsID: + result = @"ConnectMaxTimeSeconds"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeInterfaceEnabledID: + result = @"InterfaceEnabled"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeLastNetworkingStatusID: + result = @"LastNetworkingStatus"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeLastNetworkIDID: + result = @"LastNetworkID"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeLastConnectErrorValueID: + result = @"LastConnectErrorValue"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeSupportedWiFiBandsID: + result = @"SupportedWiFiBands"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeSupportedThreadFeaturesID: + result = @"SupportedThreadFeatures"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeThreadVersionID: + result = @"ThreadVersion"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterNetworkCommissioningAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDiagnosticLogsID: + + switch (attributeID) { + + // Cluster DiagnosticLogs attributes + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDiagnosticLogsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGeneralDiagnosticsID: + + switch (attributeID) { + + // Cluster GeneralDiagnostics attributes + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeNetworkInterfacesID: + result = @"NetworkInterfaces"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeRebootCountID: + result = @"RebootCount"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeUpTimeID: + result = @"UpTime"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeTotalOperationalHoursID: + result = @"TotalOperationalHours"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeBootReasonID: + result = @"BootReason"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeActiveHardwareFaultsID: + result = @"ActiveHardwareFaults"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeActiveRadioFaultsID: + result = @"ActiveRadioFaults"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeActiveNetworkFaultsID: + result = @"ActiveNetworkFaults"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeTestEventTriggersEnabledID: + result = @"TestEventTriggersEnabled"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSoftwareDiagnosticsID: + + switch (attributeID) { + + // Cluster SoftwareDiagnostics attributes + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeThreadMetricsID: + result = @"ThreadMetrics"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeCurrentHeapFreeID: + result = @"CurrentHeapFree"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeCurrentHeapUsedID: + result = @"CurrentHeapUsed"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeCurrentHeapHighWatermarkID: + result = @"CurrentHeapHighWatermark"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSoftwareDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeThreadNetworkDiagnosticsID: + + switch (attributeID) { + + // Cluster ThreadNetworkDiagnostics attributes + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeChannelID: + result = @"Channel"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRoutingRoleID: + result = @"RoutingRole"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeNetworkNameID: + result = @"NetworkName"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePanIdID: + result = @"PanId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeExtendedPanIdID: + result = @"ExtendedPanId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeMeshLocalPrefixID: + result = @"MeshLocalPrefix"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeOverrunCountID: + result = @"OverrunCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeNeighborTableID: + result = @"NeighborTable"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRouteTableID: + result = @"RouteTable"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePartitionIdID: + result = @"PartitionId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeWeightingID: + result = @"Weighting"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeDataVersionID: + result = @"DataVersion"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeStableDataVersionID: + result = @"StableDataVersion"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeLeaderRouterIdID: + result = @"LeaderRouterId"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeDetachedRoleCountID: + result = @"DetachedRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeChildRoleCountID: + result = @"ChildRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRouterRoleCountID: + result = @"RouterRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeLeaderRoleCountID: + result = @"LeaderRoleCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeAttachAttemptCountID: + result = @"AttachAttemptCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePartitionIdChangeCountID: + result = @"PartitionIdChangeCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeBetterPartitionAttachAttemptCountID: + result = @"BetterPartitionAttachAttemptCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeParentChangeCountID: + result = @"ParentChangeCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxTotalCountID: + result = @"TxTotalCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxUnicastCountID: + result = @"TxUnicastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxBroadcastCountID: + result = @"TxBroadcastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxAckRequestedCountID: + result = @"TxAckRequestedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxAckedCountID: + result = @"TxAckedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxNoAckRequestedCountID: + result = @"TxNoAckRequestedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxDataCountID: + result = @"TxDataCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxDataPollCountID: + result = @"TxDataPollCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxBeaconCountID: + result = @"TxBeaconCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxBeaconRequestCountID: + result = @"TxBeaconRequestCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxOtherCountID: + result = @"TxOtherCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxRetryCountID: + result = @"TxRetryCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxDirectMaxRetryExpiryCountID: + result = @"TxDirectMaxRetryExpiryCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxIndirectMaxRetryExpiryCountID: + result = @"TxIndirectMaxRetryExpiryCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxErrCcaCountID: + result = @"TxErrCcaCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxErrAbortCountID: + result = @"TxErrAbortCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeTxErrBusyChannelCountID: + result = @"TxErrBusyChannelCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxTotalCountID: + result = @"RxTotalCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxUnicastCountID: + result = @"RxUnicastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxBroadcastCountID: + result = @"RxBroadcastCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDataCountID: + result = @"RxDataCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDataPollCountID: + result = @"RxDataPollCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxBeaconCountID: + result = @"RxBeaconCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxBeaconRequestCountID: + result = @"RxBeaconRequestCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxOtherCountID: + result = @"RxOtherCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxAddressFilteredCountID: + result = @"RxAddressFilteredCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDestAddrFilteredCountID: + result = @"RxDestAddrFilteredCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxDuplicatedCountID: + result = @"RxDuplicatedCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrNoFrameCountID: + result = @"RxErrNoFrameCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrUnknownNeighborCountID: + result = @"RxErrUnknownNeighborCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrInvalidSrcAddrCountID: + result = @"RxErrInvalidSrcAddrCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrSecCountID: + result = @"RxErrSecCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrFcsCountID: + result = @"RxErrFcsCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeRxErrOtherCountID: + result = @"RxErrOtherCount"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeActiveTimestampID: + result = @"ActiveTimestamp"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributePendingTimestampID: + result = @"PendingTimestamp"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeDelayID: + result = @"Delay"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeSecurityPolicyID: + result = @"SecurityPolicy"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeChannelPage0MaskID: + result = @"ChannelPage0Mask"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeOperationalDatasetComponentsID: + result = @"OperationalDatasetComponents"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeActiveNetworkFaultsListID: + result = @"ActiveNetworkFaultsList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterThreadNetworkDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeWiFiNetworkDiagnosticsID: + + switch (attributeID) { + + // Cluster WiFiNetworkDiagnostics attributes + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeBSSIDID: + result = @"BSSID"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeSecurityTypeID: + result = @"SecurityType"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeWiFiVersionID: + result = @"WiFiVersion"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeChannelNumberID: + result = @"ChannelNumber"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeRSSIID: + result = @"RSSI"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeBeaconLostCountID: + result = @"BeaconLostCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeBeaconRxCountID: + result = @"BeaconRxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketMulticastRxCountID: + result = @"PacketMulticastRxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketMulticastTxCountID: + result = @"PacketMulticastTxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketUnicastRxCountID: + result = @"PacketUnicastRxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributePacketUnicastTxCountID: + result = @"PacketUnicastTxCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeCurrentMaxRateID: + result = @"CurrentMaxRate"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeOverrunCountID: + result = @"OverrunCount"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterWiFiNetworkDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEthernetNetworkDiagnosticsID: + + switch (attributeID) { + + // Cluster EthernetNetworkDiagnostics attributes + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributePHYRateID: + result = @"PHYRate"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeFullDuplexID: + result = @"FullDuplex"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributePacketRxCountID: + result = @"PacketRxCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributePacketTxCountID: + result = @"PacketTxCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeTxErrCountID: + result = @"TxErrCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeCollisionCountID: + result = @"CollisionCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeOverrunCountID: + result = @"OverrunCount"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeCarrierDetectID: + result = @"CarrierDetect"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeTimeSinceResetID: + result = @"TimeSinceReset"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEthernetNetworkDiagnosticsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTimeSynchronizationID: + + switch (attributeID) { + + // Cluster TimeSynchronization attributes + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeUTCTimeID: + result = @"UTCTime"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeGranularityID: + result = @"Granularity"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeSourceID: + result = @"TimeSource"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID: + result = @"TrustedTimeSource"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID: + result = @"DefaultNTP"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID: + result = @"TimeZone"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetID: + result = @"DSTOffset"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeLocalTimeID: + result = @"LocalTime"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneDatabaseID: + result = @"TimeZoneDatabase"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID: + result = @"NTPServerAvailable"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneListMaxSizeID: + result = @"TimeZoneListMaxSize"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetListMaxSizeID: + result = @"DSTOffsetListMaxSize"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeSupportsDNSResolveID: + result = @"SupportsDNSResolve"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTimeSynchronizationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBridgedDeviceBasicInformationID: + + switch (attributeID) { + + // Cluster BridgedDeviceBasicInformation attributes + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeVendorNameID: + result = @"VendorName"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeVendorIDID: + result = @"VendorID"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductNameID: + result = @"ProductName"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeNodeLabelID: + result = @"NodeLabel"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeHardwareVersionID: + result = @"HardwareVersion"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeHardwareVersionStringID: + result = @"HardwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeSoftwareVersionID: + result = @"SoftwareVersion"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeSoftwareVersionStringID: + result = @"SoftwareVersionString"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeManufacturingDateID: + result = @"ManufacturingDate"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributePartNumberID: + result = @"PartNumber"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductURLID: + result = @"ProductURL"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductLabelID: + result = @"ProductLabel"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeSerialNumberID: + result = @"SerialNumber"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeReachableID: + result = @"Reachable"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeUniqueIDID: + result = @"UniqueID"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductAppearanceID: + result = @"ProductAppearance"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSwitchID: + + switch (attributeID) { + + // Cluster Switch attributes + case MTRAttributeIDTypeClusterSwitchAttributeNumberOfPositionsID: + result = @"NumberOfPositions"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeCurrentPositionID: + result = @"CurrentPosition"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeMultiPressMaxID: + result = @"MultiPressMax"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSwitchAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAdministratorCommissioningID: + + switch (attributeID) { + + // Cluster AdministratorCommissioning attributes + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeWindowStatusID: + result = @"WindowStatus"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAdminFabricIndexID: + result = @"AdminFabricIndex"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAdminVendorIdID: + result = @"AdminVendorId"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAdministratorCommissioningAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOperationalCredentialsID: + + switch (attributeID) { + + // Cluster OperationalCredentials attributes + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeNOCsID: + result = @"NOCs"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeFabricsID: + result = @"Fabrics"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeSupportedFabricsID: + result = @"SupportedFabrics"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeCommissionedFabricsID: + result = @"CommissionedFabrics"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeTrustedRootCertificatesID: + result = @"TrustedRootCertificates"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeCurrentFabricIndexID: + result = @"CurrentFabricIndex"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOperationalCredentialsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeGroupKeyManagementID: + + switch (attributeID) { + + // Cluster GroupKeyManagement attributes + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeGroupKeyMapID: + result = @"GroupKeyMap"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeGroupTableID: + result = @"GroupTable"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeMaxGroupsPerFabricID: + result = @"MaxGroupsPerFabric"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeMaxGroupKeysPerFabricID: + result = @"MaxGroupKeysPerFabric"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterGroupKeyManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFixedLabelID: + + switch (attributeID) { + + // Cluster FixedLabel attributes + case MTRAttributeIDTypeClusterFixedLabelAttributeLabelListID: + result = @"LabelList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFixedLabelAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeUserLabelID: + + switch (attributeID) { + + // Cluster UserLabel attributes + case MTRAttributeIDTypeClusterUserLabelAttributeLabelListID: + result = @"LabelList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterUserLabelAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBooleanStateID: + + switch (attributeID) { + + // Cluster BooleanState attributes + case MTRAttributeIDTypeClusterBooleanStateAttributeStateValueID: + result = @"StateValue"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBooleanStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeICDManagementID: + + switch (attributeID) { + + // Cluster ICDManagement attributes + case MTRAttributeIDTypeClusterICDManagementAttributeIdleModeDurationID: + result = @"IdleModeDuration"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeActiveModeDurationID: + result = @"ActiveModeDuration"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeActiveModeThresholdID: + result = @"ActiveModeThreshold"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeRegisteredClientsID: + result = @"RegisteredClients"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeICDCounterID: + result = @"ICDCounter"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeClientsSupportedPerFabricID: + result = @"ClientsSupportedPerFabric"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeUserActiveModeTriggerHintID: + result = @"UserActiveModeTriggerHint"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeUserActiveModeTriggerInstructionID: + result = @"UserActiveModeTriggerInstruction"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeOperatingModeID: + result = @"OperatingMode"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterICDManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTimerID: + + switch (attributeID) { + + // Cluster Timer attributes + case MTRAttributeIDTypeClusterTimerAttributeSetTimeID: + result = @"SetTime"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeTimeRemainingID: + result = @"TimeRemaining"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeTimerStateID: + result = @"TimerState"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTimerAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOvenCavityOperationalStateID: + + switch (attributeID) { + + // Cluster OvenCavityOperationalState attributes + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributePhaseListID: + result = @"PhaseList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeCurrentPhaseID: + result = @"CurrentPhase"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeCountdownTimeID: + result = @"CountdownTime"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeOperationalStateListID: + result = @"OperationalStateList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeOperationalStateID: + result = @"OperationalState"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeOperationalErrorID: + result = @"OperationalError"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOvenCavityOperationalStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOvenModeID: + + switch (attributeID) { + + // Cluster OvenMode attributes + case MTRAttributeIDTypeClusterOvenModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOvenModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLaundryDryerControlsID: + + switch (attributeID) { + + // Cluster LaundryDryerControls attributes + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeSupportedDrynessLevelsID: + result = @"SupportedDrynessLevels"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeSelectedDrynessLevelID: + result = @"SelectedDrynessLevel"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLaundryDryerControlsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeModeSelectID: + + switch (attributeID) { + + // Cluster ModeSelect attributes + case MTRAttributeIDTypeClusterModeSelectAttributeDescriptionID: + result = @"Description"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeStandardNamespaceID: + result = @"StandardNamespace"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterModeSelectAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLaundryWasherModeID: + + switch (attributeID) { + + // Cluster LaundryWasherMode attributes + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRefrigeratorAndTemperatureControlledCabinetModeID: + + switch (attributeID) { + + // Cluster RefrigeratorAndTemperatureControlledCabinetMode attributes + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAndTemperatureControlledCabinetModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLaundryWasherControlsID: + + switch (attributeID) { + + // Cluster LaundryWasherControls attributes + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeSpinSpeedsID: + result = @"SpinSpeeds"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeSpinSpeedCurrentID: + result = @"SpinSpeedCurrent"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeNumberOfRinsesID: + result = @"NumberOfRinses"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeSupportedRinsesID: + result = @"SupportedRinses"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLaundryWasherControlsAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRVCRunModeID: + + switch (attributeID) { + + // Cluster RVCRunMode attributes + case MTRAttributeIDTypeClusterRVCRunModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRVCRunModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRVCCleanModeID: + + switch (attributeID) { + + // Cluster RVCCleanMode attributes + case MTRAttributeIDTypeClusterRVCCleanModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRVCCleanModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTemperatureControlID: + + switch (attributeID) { + + // Cluster TemperatureControl attributes + case MTRAttributeIDTypeClusterTemperatureControlAttributeTemperatureSetpointID: + result = @"TemperatureSetpoint"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeMinTemperatureID: + result = @"MinTemperature"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeMaxTemperatureID: + result = @"MaxTemperature"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeStepID: + result = @"Step"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeSelectedTemperatureLevelID: + result = @"SelectedTemperatureLevel"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeSupportedTemperatureLevelsID: + result = @"SupportedTemperatureLevels"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTemperatureControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRefrigeratorAlarmID: + + switch (attributeID) { + + // Cluster RefrigeratorAlarm attributes + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeMaskID: + result = @"Mask"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeStateID: + result = @"State"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeSupportedID: + result = @"Supported"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRefrigeratorAlarmAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDishwasherModeID: + + switch (attributeID) { + + // Cluster DishwasherMode attributes + case MTRAttributeIDTypeClusterDishwasherModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDishwasherModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAirQualityID: + + switch (attributeID) { + + // Cluster AirQuality attributes + case MTRAttributeIDTypeClusterAirQualityAttributeAirQualityID: + result = @"AirQuality"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAirQualityAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSmokeCOAlarmID: + + switch (attributeID) { + + // Cluster SmokeCOAlarm attributes + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeExpressedStateID: + result = @"ExpressedState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeSmokeStateID: + result = @"SmokeState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeCOStateID: + result = @"COState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeBatteryAlertID: + result = @"BatteryAlert"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeDeviceMutedID: + result = @"DeviceMuted"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeTestInProgressID: + result = @"TestInProgress"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeHardwareFaultAlertID: + result = @"HardwareFaultAlert"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeEndOfServiceAlertID: + result = @"EndOfServiceAlert"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeInterconnectSmokeAlarmID: + result = @"InterconnectSmokeAlarm"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeInterconnectCOAlarmID: + result = @"InterconnectCOAlarm"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeContaminationStateID: + result = @"ContaminationState"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeSmokeSensitivityLevelID: + result = @"SmokeSensitivityLevel"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeExpiryDateID: + result = @"ExpiryDate"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSmokeCOAlarmAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDishwasherAlarmID: + + switch (attributeID) { + + // Cluster DishwasherAlarm attributes + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeMaskID: + result = @"Mask"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeLatchID: + result = @"Latch"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeStateID: + result = @"State"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeSupportedID: + result = @"Supported"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDishwasherAlarmAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMicrowaveOvenModeID: + + switch (attributeID) { + + // Cluster MicrowaveOvenMode attributes + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMicrowaveOvenControlID: + + switch (attributeID) { + + // Cluster MicrowaveOvenControl attributes + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeCookTimeID: + result = @"CookTime"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeMaxCookTimeID: + result = @"MaxCookTime"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributePowerSettingID: + result = @"PowerSetting"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeMinPowerID: + result = @"MinPower"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeMaxPowerID: + result = @"MaxPower"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributePowerStepID: + result = @"PowerStep"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeSupportedWattsID: + result = @"SupportedWatts"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeSelectedWattIndexID: + result = @"SelectedWattIndex"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeWattRatingID: + result = @"WattRating"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMicrowaveOvenControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOperationalStateID: + + switch (attributeID) { + + // Cluster OperationalState attributes + case MTRAttributeIDTypeClusterOperationalStateAttributePhaseListID: + result = @"PhaseList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeCurrentPhaseID: + result = @"CurrentPhase"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeCountdownTimeID: + result = @"CountdownTime"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeOperationalStateListID: + result = @"OperationalStateList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeOperationalStateID: + result = @"OperationalState"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeOperationalErrorID: + result = @"OperationalError"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOperationalStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRVCOperationalStateID: + + switch (attributeID) { + + // Cluster RVCOperationalState attributes + case MTRAttributeIDTypeClusterRVCOperationalStateAttributePhaseListID: + result = @"PhaseList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeCurrentPhaseID: + result = @"CurrentPhase"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeCountdownTimeID: + result = @"CountdownTime"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateListID: + result = @"OperationalStateList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateID: + result = @"OperationalState"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalErrorID: + result = @"OperationalError"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRVCOperationalStateAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeScenesManagementID: + + switch (attributeID) { + + // Cluster ScenesManagement attributes + case MTRAttributeIDTypeClusterScenesManagementAttributeLastConfiguredByID: + result = @"LastConfiguredBy"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeSceneTableSizeID: + result = @"SceneTableSize"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeFabricSceneInfoID: + result = @"FabricSceneInfo"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterScenesManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeHEPAFilterMonitoringID: + + switch (attributeID) { + + // Cluster HEPAFilterMonitoring attributes + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeConditionID: + result = @"Condition"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeDegradationDirectionID: + result = @"DegradationDirection"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeChangeIndicationID: + result = @"ChangeIndication"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeInPlaceIndicatorID: + result = @"InPlaceIndicator"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeLastChangedTimeID: + result = @"LastChangedTime"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeReplacementProductListID: + result = @"ReplacementProductList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeActivatedCarbonFilterMonitoringID: + + switch (attributeID) { + + // Cluster ActivatedCarbonFilterMonitoring attributes + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeConditionID: + result = @"Condition"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeDegradationDirectionID: + result = @"DegradationDirection"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeChangeIndicationID: + result = @"ChangeIndication"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeInPlaceIndicatorID: + result = @"InPlaceIndicator"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeLastChangedTimeID: + result = @"LastChangedTime"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeReplacementProductListID: + result = @"ReplacementProductList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterActivatedCarbonFilterMonitoringAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBooleanStateConfigurationID: + + switch (attributeID) { + + // Cluster BooleanStateConfiguration attributes + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeCurrentSensitivityLevelID: + result = @"CurrentSensitivityLevel"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeSupportedSensitivityLevelsID: + result = @"SupportedSensitivityLevels"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeDefaultSensitivityLevelID: + result = @"DefaultSensitivityLevel"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsActiveID: + result = @"AlarmsActive"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsSuppressedID: + result = @"AlarmsSuppressed"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsEnabledID: + result = @"AlarmsEnabled"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAlarmsSupportedID: + result = @"AlarmsSupported"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeSensorFaultID: + result = @"SensorFault"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBooleanStateConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeValveConfigurationAndControlID: + + switch (attributeID) { + + // Cluster ValveConfigurationAndControl attributes + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeOpenDurationID: + result = @"OpenDuration"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeDefaultOpenDurationID: + result = @"DefaultOpenDuration"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeAutoCloseTimeID: + result = @"AutoCloseTime"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeRemainingDurationID: + result = @"RemainingDuration"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeCurrentStateID: + result = @"CurrentState"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeTargetStateID: + result = @"TargetState"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeCurrentLevelID: + result = @"CurrentLevel"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeTargetLevelID: + result = @"TargetLevel"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeDefaultOpenLevelID: + result = @"DefaultOpenLevel"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeValveFaultID: + result = @"ValveFault"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeLevelStepID: + result = @"LevelStep"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterValveConfigurationAndControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeElectricalPowerMeasurementID: + + switch (attributeID) { + + // Cluster ElectricalPowerMeasurement attributes + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerModeID: + result = @"PowerMode"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNumberOfMeasurementTypesID: + result = @"NumberOfMeasurementTypes"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAccuracyID: + result = @"Accuracy"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRangesID: + result = @"Ranges"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeVoltageID: + result = @"Voltage"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActiveCurrentID: + result = @"ActiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactiveCurrentID: + result = @"ReactiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentCurrentID: + result = @"ApparentCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeActivePowerID: + result = @"ActivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeReactivePowerID: + result = @"ReactivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeApparentPowerID: + result = @"ApparentPower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSVoltageID: + result = @"RMSVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSCurrentID: + result = @"RMSCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeRMSPowerID: + result = @"RMSPower"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFrequencyID: + result = @"Frequency"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicCurrentsID: + result = @"HarmonicCurrents"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeHarmonicPhasesID: + result = @"HarmonicPhases"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributePowerFactorID: + result = @"PowerFactor"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeNeutralCurrentID: + result = @"NeutralCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterElectricalPowerMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeElectricalEnergyMeasurementID: + + switch (attributeID) { + + // Cluster ElectricalEnergyMeasurement attributes + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAccuracyID: + result = @"Accuracy"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyImportedID: + result = @"CumulativeEnergyImported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyExportedID: + result = @"CumulativeEnergyExported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyImportedID: + result = @"PeriodicEnergyImported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributePeriodicEnergyExportedID: + result = @"PeriodicEnergyExported"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeCumulativeEnergyResetID: + result = @"CumulativeEnergyReset"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterElectricalEnergyMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDemandResponseLoadControlID: + + switch (attributeID) { + + // Cluster DemandResponseLoadControl attributes + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeLoadControlProgramsID: + result = @"LoadControlPrograms"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfLoadControlProgramsID: + result = @"NumberOfLoadControlPrograms"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeEventsID: + result = @"Events"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeActiveEventsID: + result = @"ActiveEvents"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfEventsPerProgramID: + result = @"NumberOfEventsPerProgram"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeNumberOfTransitionsID: + result = @"NumberOfTransitions"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeDefaultRandomStartID: + result = @"DefaultRandomStart"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeDefaultRandomDurationID: + result = @"DefaultRandomDuration"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDemandResponseLoadControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMessagesID: + + switch (attributeID) { + + // Cluster Messages attributes + case MTRAttributeIDTypeClusterMessagesAttributeMessagesID: + result = @"Messages"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeActiveMessageIDsID: + result = @"ActiveMessageIDs"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMessagesAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDeviceEnergyManagementID: + + switch (attributeID) { + + // Cluster DeviceEnergyManagement attributes + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESATypeID: + result = @"ESAType"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESACanGenerateID: + result = @"ESACanGenerate"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESAStateID: + result = @"ESAState"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAbsMinPowerID: + result = @"AbsMinPower"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAbsMaxPowerID: + result = @"AbsMaxPower"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributePowerAdjustmentCapabilityID: + result = @"PowerAdjustmentCapability"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeForecastID: + result = @"Forecast"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeOptOutStateID: + result = @"OptOutState"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEnergyEVSEID: + + switch (attributeID) { + + // Cluster EnergyEVSE attributes + case MTRAttributeIDTypeClusterEnergyEVSEAttributeStateID: + result = @"State"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSupplyStateID: + result = @"SupplyState"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeFaultStateID: + result = @"FaultState"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeChargingEnabledUntilID: + result = @"ChargingEnabledUntil"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeDischargingEnabledUntilID: + result = @"DischargingEnabledUntil"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeCircuitCapacityID: + result = @"CircuitCapacity"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeMinimumChargeCurrentID: + result = @"MinimumChargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeMaximumChargeCurrentID: + result = @"MaximumChargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeMaximumDischargeCurrentID: + result = @"MaximumDischargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeUserMaximumChargeCurrentID: + result = @"UserMaximumChargeCurrent"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeRandomizationDelayWindowID: + result = @"RandomizationDelayWindow"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeStartTimeID: + result = @"NextChargeStartTime"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeTargetTimeID: + result = @"NextChargeTargetTime"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeRequiredEnergyID: + result = @"NextChargeRequiredEnergy"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeNextChargeTargetSoCID: + result = @"NextChargeTargetSoC"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeApproximateEVEfficiencyID: + result = @"ApproximateEVEfficiency"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeStateOfChargeID: + result = @"StateOfCharge"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeBatteryCapacityID: + result = @"BatteryCapacity"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeVehicleIDID: + result = @"VehicleID"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionIDID: + result = @"SessionID"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionDurationID: + result = @"SessionDuration"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionEnergyChargedID: + result = @"SessionEnergyCharged"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeSessionEnergyDischargedID: + result = @"SessionEnergyDischarged"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEnergyPreferenceID: + + switch (attributeID) { + + // Cluster EnergyPreference attributes + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeEnergyBalancesID: + result = @"EnergyBalances"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeCurrentEnergyBalanceID: + result = @"CurrentEnergyBalance"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeEnergyPrioritiesID: + result = @"EnergyPriorities"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeLowPowerModeSensitivitiesID: + result = @"LowPowerModeSensitivities"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeCurrentLowPowerModeSensitivityID: + result = @"CurrentLowPowerModeSensitivity"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEnergyPreferenceAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeEnergyEVSEModeID: + + switch (attributeID) { + + // Cluster EnergyEVSEMode attributes + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterEnergyEVSEModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDeviceEnergyManagementModeID: + + switch (attributeID) { + + // Cluster DeviceEnergyManagementMode attributes + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeSupportedModesID: + result = @"SupportedModes"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeCurrentModeID: + result = @"CurrentMode"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeStartUpModeID: + result = @"StartUpMode"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeOnModeID: + result = @"OnMode"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDeviceEnergyManagementModeAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeDoorLockID: + + switch (attributeID) { + + // Cluster DoorLock attributes + case MTRAttributeIDTypeClusterDoorLockAttributeLockStateID: + result = @"LockState"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLockTypeID: + result = @"LockType"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeActuatorEnabledID: + result = @"ActuatorEnabled"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDoorStateID: + result = @"DoorState"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDoorOpenEventsID: + result = @"DoorOpenEvents"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDoorClosedEventsID: + result = @"DoorClosedEvents"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeOpenPeriodID: + result = @"OpenPeriod"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfTotalUsersSupportedID: + result = @"NumberOfTotalUsersSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfPINUsersSupportedID: + result = @"NumberOfPINUsersSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfRFIDUsersSupportedID: + result = @"NumberOfRFIDUsersSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfWeekDaySchedulesSupportedPerUserID: + result = @"NumberOfWeekDaySchedulesSupportedPerUser"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfYearDaySchedulesSupportedPerUserID: + result = @"NumberOfYearDaySchedulesSupportedPerUser"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfHolidaySchedulesSupportedID: + result = @"NumberOfHolidaySchedulesSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMaxPINCodeLengthID: + result = @"MaxPINCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMinPINCodeLengthID: + result = @"MinPINCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMaxRFIDCodeLengthID: + result = @"MaxRFIDCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeMinRFIDCodeLengthID: + result = @"MinRFIDCodeLength"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeCredentialRulesSupportID: + result = @"CredentialRulesSupport"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfCredentialsSupportedPerUserID: + result = @"NumberOfCredentialsSupportedPerUser"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLanguageID: + result = @"Language"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLEDSettingsID: + result = @"LEDSettings"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAutoRelockTimeID: + result = @"AutoRelockTime"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeSoundVolumeID: + result = @"SoundVolume"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeOperatingModeID: + result = @"OperatingMode"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeSupportedOperatingModesID: + result = @"SupportedOperatingModes"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeDefaultConfigurationRegisterID: + result = @"DefaultConfigurationRegister"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnableLocalProgrammingID: + result = @"EnableLocalProgramming"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnableOneTouchLockingID: + result = @"EnableOneTouchLocking"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnableInsideStatusLEDID: + result = @"EnableInsideStatusLED"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEnablePrivacyModeButtonID: + result = @"EnablePrivacyModeButton"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeLocalProgrammingFeaturesID: + result = @"LocalProgrammingFeatures"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeWrongCodeEntryLimitID: + result = @"WrongCodeEntryLimit"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeUserCodeTemporaryDisableTimeID: + result = @"UserCodeTemporaryDisableTime"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeSendPINOverTheAirID: + result = @"SendPINOverTheAir"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeRequirePINforRemoteOperationID: + result = @"RequirePINforRemoteOperation"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeExpiringUserTimeoutID: + result = @"ExpiringUserTimeout"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroReaderVerificationKeyID: + result = @"AliroReaderVerificationKey"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroReaderGroupIdentifierID: + result = @"AliroReaderGroupIdentifier"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroReaderGroupSubIdentifierID: + result = @"AliroReaderGroupSubIdentifier"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroExpeditedTransactionSupportedProtocolVersionsID: + result = @"AliroExpeditedTransactionSupportedProtocolVersions"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroGroupResolvingKeyID: + result = @"AliroGroupResolvingKey"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroSupportedBLEUWBProtocolVersionsID: + result = @"AliroSupportedBLEUWBProtocolVersions"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAliroBLEAdvertisingVersionID: + result = @"AliroBLEAdvertisingVersion"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfAliroCredentialIssuerKeysSupportedID: + result = @"NumberOfAliroCredentialIssuerKeysSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeNumberOfAliroEndpointKeysSupportedID: + result = @"NumberOfAliroEndpointKeysSupported"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterDoorLockAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeWindowCoveringID: + + switch (attributeID) { + + // Cluster WindowCovering attributes + case MTRAttributeIDTypeClusterWindowCoveringAttributeTypeID: + result = @"Type"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributePhysicalClosedLimitLiftID: + result = @"PhysicalClosedLimitLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributePhysicalClosedLimitTiltID: + result = @"PhysicalClosedLimitTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionLiftID: + result = @"CurrentPositionLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionTiltID: + result = @"CurrentPositionTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeNumberOfActuationsLiftID: + result = @"NumberOfActuationsLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeNumberOfActuationsTiltID: + result = @"NumberOfActuationsTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeConfigStatusID: + result = @"ConfigStatus"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionLiftPercentageID: + result = @"CurrentPositionLiftPercentage"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionTiltPercentageID: + result = @"CurrentPositionTiltPercentage"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeOperationalStatusID: + result = @"OperationalStatus"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeTargetPositionLiftPercent100thsID: + result = @"TargetPositionLiftPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeTargetPositionTiltPercent100thsID: + result = @"TargetPositionTiltPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeEndProductTypeID: + result = @"EndProductType"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionLiftPercent100thsID: + result = @"CurrentPositionLiftPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeCurrentPositionTiltPercent100thsID: + result = @"CurrentPositionTiltPercent100ths"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledOpenLimitLiftID: + result = @"InstalledOpenLimitLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledClosedLimitLiftID: + result = @"InstalledClosedLimitLift"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledOpenLimitTiltID: + result = @"InstalledOpenLimitTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeInstalledClosedLimitTiltID: + result = @"InstalledClosedLimitTilt"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeModeID: + result = @"Mode"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeSafetyStatusID: + result = @"SafetyStatus"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterWindowCoveringAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBarrierControlID: + + switch (attributeID) { + + // Cluster BarrierControl attributes + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierMovingStateID: + result = @"BarrierMovingState"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierSafetyStatusID: + result = @"BarrierSafetyStatus"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCapabilitiesID: + result = @"BarrierCapabilities"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierOpenEventsID: + result = @"BarrierOpenEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCloseEventsID: + result = @"BarrierCloseEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCommandOpenEventsID: + result = @"BarrierCommandOpenEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierCommandCloseEventsID: + result = @"BarrierCommandCloseEvents"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierOpenPeriodID: + result = @"BarrierOpenPeriod"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierClosePeriodID: + result = @"BarrierClosePeriod"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeBarrierPositionID: + result = @"BarrierPosition"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBarrierControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePumpConfigurationAndControlID: + + switch (attributeID) { + + // Cluster PumpConfigurationAndControl attributes + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxPressureID: + result = @"MaxPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxSpeedID: + result = @"MaxSpeed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxFlowID: + result = @"MaxFlow"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstPressureID: + result = @"MinConstPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstPressureID: + result = @"MaxConstPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinCompPressureID: + result = @"MinCompPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxCompPressureID: + result = @"MaxCompPressure"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstSpeedID: + result = @"MinConstSpeed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstSpeedID: + result = @"MaxConstSpeed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstFlowID: + result = @"MinConstFlow"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstFlowID: + result = @"MaxConstFlow"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMinConstTempID: + result = @"MinConstTemp"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeMaxConstTempID: + result = @"MaxConstTemp"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributePumpStatusID: + result = @"PumpStatus"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeEffectiveOperationModeID: + result = @"EffectiveOperationMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeEffectiveControlModeID: + result = @"EffectiveControlMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeCapacityID: + result = @"Capacity"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeSpeedID: + result = @"Speed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeLifetimeRunningHoursID: + result = @"LifetimeRunningHours"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributePowerID: + result = @"Power"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeLifetimeEnergyConsumedID: + result = @"LifetimeEnergyConsumed"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeOperationModeID: + result = @"OperationMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeControlModeID: + result = @"ControlMode"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPumpConfigurationAndControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeThermostatID: + + switch (attributeID) { + + // Cluster Thermostat attributes + case MTRAttributeIDTypeClusterThermostatAttributeLocalTemperatureID: + result = @"LocalTemperature"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOutdoorTemperatureID: + result = @"OutdoorTemperature"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupancyID: + result = @"Occupancy"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMinHeatSetpointLimitID: + result = @"AbsMinHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMaxHeatSetpointLimitID: + result = @"AbsMaxHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMinCoolSetpointLimitID: + result = @"AbsMinCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAbsMaxCoolSetpointLimitID: + result = @"AbsMaxCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePICoolingDemandID: + result = @"PICoolingDemand"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePIHeatingDemandID: + result = @"PIHeatingDemand"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeHVACSystemTypeConfigurationID: + result = @"HVACSystemTypeConfiguration"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeLocalTemperatureCalibrationID: + result = @"LocalTemperatureCalibration"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedCoolingSetpointID: + result = @"OccupiedCoolingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedHeatingSetpointID: + result = @"OccupiedHeatingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedCoolingSetpointID: + result = @"UnoccupiedCoolingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedHeatingSetpointID: + result = @"UnoccupiedHeatingSetpoint"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMinHeatSetpointLimitID: + result = @"MinHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMaxHeatSetpointLimitID: + result = @"MaxHeatSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMinCoolSetpointLimitID: + result = @"MinCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMaxCoolSetpointLimitID: + result = @"MaxCoolSetpointLimit"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeMinSetpointDeadBandID: + result = @"MinSetpointDeadBand"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeRemoteSensingID: + result = @"RemoteSensing"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeControlSequenceOfOperationID: + result = @"ControlSequenceOfOperation"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSystemModeID: + result = @"SystemMode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeThermostatRunningModeID: + result = @"ThermostatRunningMode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeStartOfWeekID: + result = @"StartOfWeek"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfWeeklyTransitionsID: + result = @"NumberOfWeeklyTransitions"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfDailyTransitionsID: + result = @"NumberOfDailyTransitions"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeTemperatureSetpointHoldID: + result = @"TemperatureSetpointHold"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeTemperatureSetpointHoldDurationID: + result = @"TemperatureSetpointHoldDuration"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeThermostatProgrammingOperationModeID: + result = @"ThermostatProgrammingOperationMode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeThermostatRunningStateID: + result = @"ThermostatRunningState"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointChangeSourceID: + result = @"SetpointChangeSource"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointChangeAmountID: + result = @"SetpointChangeAmount"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointChangeSourceTimestampID: + result = @"SetpointChangeSourceTimestamp"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedSetbackID: + result = @"OccupiedSetback"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedSetbackMinID: + result = @"OccupiedSetbackMin"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeOccupiedSetbackMaxID: + result = @"OccupiedSetbackMax"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedSetbackID: + result = @"UnoccupiedSetback"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedSetbackMinID: + result = @"UnoccupiedSetbackMin"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeUnoccupiedSetbackMaxID: + result = @"UnoccupiedSetbackMax"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeEmergencyHeatDeltaID: + result = @"EmergencyHeatDelta"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACTypeID: + result = @"ACType"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCapacityID: + result = @"ACCapacity"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACRefrigerantTypeID: + result = @"ACRefrigerantType"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCompressorTypeID: + result = @"ACCompressorType"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACErrorCodeID: + result = @"ACErrorCode"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACLouverPositionID: + result = @"ACLouverPosition"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCoilTemperatureID: + result = @"ACCoilTemperature"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeACCapacityformatID: + result = @"ACCapacityformat"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePresetTypesID: + result = @"PresetTypes"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeScheduleTypesID: + result = @"ScheduleTypes"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfPresetsID: + result = @"NumberOfPresets"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfSchedulesID: + result = @"NumberOfSchedules"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfScheduleTransitionsID: + result = @"NumberOfScheduleTransitions"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeNumberOfScheduleTransitionPerDayID: + result = @"NumberOfScheduleTransitionPerDay"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeActivePresetHandleID: + result = @"ActivePresetHandle"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeActiveScheduleHandleID: + result = @"ActiveScheduleHandle"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePresetsID: + result = @"Presets"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSchedulesID: + result = @"Schedules"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributePresetsSchedulesEditableID: + result = @"PresetsSchedulesEditable"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeTemperatureSetpointHoldPolicyID: + result = @"TemperatureSetpointHoldPolicy"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeSetpointHoldExpiryTimestampID: + result = @"SetpointHoldExpiryTimestamp"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeQueuedPresetID: + result = @"QueuedPreset"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterThermostatAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFanControlID: + + switch (attributeID) { + + // Cluster FanControl attributes + case MTRAttributeIDTypeClusterFanControlAttributeFanModeID: + result = @"FanMode"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeFanModeSequenceID: + result = @"FanModeSequence"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributePercentSettingID: + result = @"PercentSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributePercentCurrentID: + result = @"PercentCurrent"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeSpeedMaxID: + result = @"SpeedMax"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeSpeedSettingID: + result = @"SpeedSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeSpeedCurrentID: + result = @"SpeedCurrent"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeRockSupportID: + result = @"RockSupport"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeRockSettingID: + result = @"RockSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeWindSupportID: + result = @"WindSupport"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeWindSettingID: + result = @"WindSetting"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeAirflowDirectionID: + result = @"AirflowDirection"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFanControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeThermostatUserInterfaceConfigurationID: + + switch (attributeID) { + + // Cluster ThermostatUserInterfaceConfiguration attributes + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeTemperatureDisplayModeID: + result = @"TemperatureDisplayMode"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeKeypadLockoutID: + result = @"KeypadLockout"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeScheduleProgrammingVisibilityID: + result = @"ScheduleProgrammingVisibility"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterThermostatUserInterfaceConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeColorControlID: + + switch (attributeID) { + + // Cluster ColorControl attributes + case MTRAttributeIDTypeClusterColorControlAttributeCurrentHueID: + result = @"CurrentHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCurrentSaturationID: + result = @"CurrentSaturation"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeRemainingTimeID: + result = @"RemainingTime"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCurrentXID: + result = @"CurrentX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCurrentYID: + result = @"CurrentY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeDriftCompensationID: + result = @"DriftCompensation"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCompensationTextID: + result = @"CompensationText"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorTemperatureMiredsID: + result = @"ColorTemperatureMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorModeID: + result = @"ColorMode"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeOptionsID: + result = @"Options"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeNumberOfPrimariesID: + result = @"NumberOfPrimaries"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary1XID: + result = @"Primary1X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary1YID: + result = @"Primary1Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary1IntensityID: + result = @"Primary1Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary2XID: + result = @"Primary2X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary2YID: + result = @"Primary2Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary2IntensityID: + result = @"Primary2Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary3XID: + result = @"Primary3X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary3YID: + result = @"Primary3Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary3IntensityID: + result = @"Primary3Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary4XID: + result = @"Primary4X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary4YID: + result = @"Primary4Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary4IntensityID: + result = @"Primary4Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary5XID: + result = @"Primary5X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary5YID: + result = @"Primary5Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary5IntensityID: + result = @"Primary5Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary6XID: + result = @"Primary6X"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary6YID: + result = @"Primary6Y"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributePrimary6IntensityID: + result = @"Primary6Intensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeWhitePointXID: + result = @"WhitePointX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeWhitePointYID: + result = @"WhitePointY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointRXID: + result = @"ColorPointRX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointRYID: + result = @"ColorPointRY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointRIntensityID: + result = @"ColorPointRIntensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointGXID: + result = @"ColorPointGX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointGYID: + result = @"ColorPointGY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointGIntensityID: + result = @"ColorPointGIntensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointBXID: + result = @"ColorPointBX"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointBYID: + result = @"ColorPointBY"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorPointBIntensityID: + result = @"ColorPointBIntensity"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeEnhancedCurrentHueID: + result = @"EnhancedCurrentHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeEnhancedColorModeID: + result = @"EnhancedColorMode"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopActiveID: + result = @"ColorLoopActive"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopDirectionID: + result = @"ColorLoopDirection"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopTimeID: + result = @"ColorLoopTime"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopStartEnhancedHueID: + result = @"ColorLoopStartEnhancedHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorLoopStoredEnhancedHueID: + result = @"ColorLoopStoredEnhancedHue"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorCapabilitiesID: + result = @"ColorCapabilities"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorTempPhysicalMinMiredsID: + result = @"ColorTempPhysicalMinMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeColorTempPhysicalMaxMiredsID: + result = @"ColorTempPhysicalMaxMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeCoupleColorTempToLevelMinMiredsID: + result = @"CoupleColorTempToLevelMinMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeStartUpColorTemperatureMiredsID: + result = @"StartUpColorTemperatureMireds"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterColorControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeBallastConfigurationID: + + switch (attributeID) { + + // Cluster BallastConfiguration attributes + case MTRAttributeIDTypeClusterBallastConfigurationAttributePhysicalMinLevelID: + result = @"PhysicalMinLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributePhysicalMaxLevelID: + result = @"PhysicalMaxLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeBallastStatusID: + result = @"BallastStatus"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeMinLevelID: + result = @"MinLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeMaxLevelID: + result = @"MaxLevel"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeIntrinsicBallastFactorID: + result = @"IntrinsicBallastFactor"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeBallastFactorAdjustmentID: + result = @"BallastFactorAdjustment"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampQuantityID: + result = @"LampQuantity"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampTypeID: + result = @"LampType"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampManufacturerID: + result = @"LampManufacturer"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampRatedHoursID: + result = @"LampRatedHours"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampBurnHoursID: + result = @"LampBurnHours"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampAlarmModeID: + result = @"LampAlarmMode"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeLampBurnHoursTripPointID: + result = @"LampBurnHoursTripPoint"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterBallastConfigurationAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeIlluminanceMeasurementID: + + switch (attributeID) { + + // Cluster IlluminanceMeasurement attributes + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeLightSensorTypeID: + result = @"LightSensorType"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterIlluminanceMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTemperatureMeasurementID: + + switch (attributeID) { + + // Cluster TemperatureMeasurement attributes + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTemperatureMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePressureMeasurementID: + + switch (attributeID) { + + // Cluster PressureMeasurement attributes + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeScaledValueID: + result = @"ScaledValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMinScaledValueID: + result = @"MinScaledValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeMaxScaledValueID: + result = @"MaxScaledValue"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeScaledToleranceID: + result = @"ScaledTolerance"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeScaleID: + result = @"Scale"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPressureMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFlowMeasurementID: + + switch (attributeID) { + + // Cluster FlowMeasurement attributes + case MTRAttributeIDTypeClusterFlowMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFlowMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRelativeHumidityMeasurementID: + + switch (attributeID) { + + // Cluster RelativeHumidityMeasurement attributes + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeToleranceID: + result = @"Tolerance"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRelativeHumidityMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOccupancySensingID: + + switch (attributeID) { + + // Cluster OccupancySensing attributes + case MTRAttributeIDTypeClusterOccupancySensingAttributeOccupancyID: + result = @"Occupancy"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeOccupancySensorTypeID: + result = @"OccupancySensorType"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeOccupancySensorTypeBitmapID: + result = @"OccupancySensorTypeBitmap"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePIROccupiedToUnoccupiedDelayID: + result = @"PIROccupiedToUnoccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePIRUnoccupiedToOccupiedDelayID: + result = @"PIRUnoccupiedToOccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePIRUnoccupiedToOccupiedThresholdID: + result = @"PIRUnoccupiedToOccupiedThreshold"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeUltrasonicOccupiedToUnoccupiedDelayID: + result = @"UltrasonicOccupiedToUnoccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedDelayID: + result = @"UltrasonicUnoccupiedToOccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedThresholdID: + result = @"UltrasonicUnoccupiedToOccupiedThreshold"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePhysicalContactOccupiedToUnoccupiedDelayID: + result = @"PhysicalContactOccupiedToUnoccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedDelayID: + result = @"PhysicalContactUnoccupiedToOccupiedDelay"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedThresholdID: + result = @"PhysicalContactUnoccupiedToOccupiedThreshold"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOccupancySensingAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeCarbonMonoxideConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster CarbonMonoxideConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterCarbonMonoxideConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeCarbonDioxideConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster CarbonDioxideConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterCarbonDioxideConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeNitrogenDioxideConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster NitrogenDioxideConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterNitrogenDioxideConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeOzoneConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster OzoneConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterOzoneConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePM25ConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster PM25ConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPM25ConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeFormaldehydeConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster FormaldehydeConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterFormaldehydeConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePM1ConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster PM1ConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPM1ConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypePM10ConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster PM10ConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterPM10ConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTotalVolatileOrganicCompoundsConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster TotalVolatileOrganicCompoundsConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTotalVolatileOrganicCompoundsConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeRadonConcentrationMeasurementID: + + switch (attributeID) { + + // Cluster RadonConcentrationMeasurement attributes + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMeasuredValueID: + result = @"MeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMinMeasuredValueID: + result = @"MinMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMaxMeasuredValueID: + result = @"MaxMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributePeakMeasuredValueID: + result = @"PeakMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributePeakMeasuredValueWindowID: + result = @"PeakMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAverageMeasuredValueID: + result = @"AverageMeasuredValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAverageMeasuredValueWindowID: + result = @"AverageMeasuredValueWindow"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeUncertaintyID: + result = @"Uncertainty"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMeasurementUnitID: + result = @"MeasurementUnit"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeMeasurementMediumID: + result = @"MeasurementMedium"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeLevelValueID: + result = @"LevelValue"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterRadonConcentrationMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeWakeOnLANID: + + switch (attributeID) { + + // Cluster WakeOnLAN attributes + case MTRAttributeIDTypeClusterWakeOnLANAttributeMACAddressID: + result = @"MACAddress"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeLinkLocalAddressID: + result = @"LinkLocalAddress"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterWakeOnLANAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeChannelID: + + switch (attributeID) { + + // Cluster Channel attributes + case MTRAttributeIDTypeClusterChannelAttributeChannelListID: + result = @"ChannelList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeLineupID: + result = @"Lineup"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeCurrentChannelID: + result = @"CurrentChannel"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterChannelAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeTargetNavigatorID: + + switch (attributeID) { + + // Cluster TargetNavigator attributes + case MTRAttributeIDTypeClusterTargetNavigatorAttributeTargetListID: + result = @"TargetList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeCurrentTargetID: + result = @"CurrentTarget"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterTargetNavigatorAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMediaPlaybackID: + + switch (attributeID) { + + // Cluster MediaPlayback attributes + case MTRAttributeIDTypeClusterMediaPlaybackAttributeCurrentStateID: + result = @"CurrentState"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeStartTimeID: + result = @"StartTime"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeDurationID: + result = @"Duration"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeSampledPositionID: + result = @"SampledPosition"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributePlaybackSpeedID: + result = @"PlaybackSpeed"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeSeekRangeEndID: + result = @"SeekRangeEnd"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeSeekRangeStartID: + result = @"SeekRangeStart"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeActiveAudioTrackID: + result = @"ActiveAudioTrack"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAvailableAudioTracksID: + result = @"AvailableAudioTracks"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeActiveTextTrackID: + result = @"ActiveTextTrack"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAvailableTextTracksID: + result = @"AvailableTextTracks"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMediaPlaybackAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeMediaInputID: + + switch (attributeID) { + + // Cluster MediaInput attributes + case MTRAttributeIDTypeClusterMediaInputAttributeInputListID: + result = @"InputList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeCurrentInputID: + result = @"CurrentInput"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterMediaInputAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeLowPowerID: + + switch (attributeID) { + + // Cluster LowPower attributes + case MTRAttributeIDTypeClusterLowPowerAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterLowPowerAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeKeypadInputID: + + switch (attributeID) { + + // Cluster KeypadInput attributes + case MTRAttributeIDTypeClusterKeypadInputAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterKeypadInputAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeContentLauncherID: + + switch (attributeID) { + + // Cluster ContentLauncher attributes + case MTRAttributeIDTypeClusterContentLauncherAttributeAcceptHeaderID: + result = @"AcceptHeader"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeSupportedStreamingProtocolsID: + result = @"SupportedStreamingProtocols"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterContentLauncherAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAudioOutputID: + + switch (attributeID) { + + // Cluster AudioOutput attributes + case MTRAttributeIDTypeClusterAudioOutputAttributeOutputListID: + result = @"OutputList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeCurrentOutputID: + result = @"CurrentOutput"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAudioOutputAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeApplicationLauncherID: + + switch (attributeID) { + + // Cluster ApplicationLauncher attributes + case MTRAttributeIDTypeClusterApplicationLauncherAttributeCatalogListID: + result = @"CatalogList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeCurrentAppID: + result = @"CurrentApp"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterApplicationLauncherAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeApplicationBasicID: + + switch (attributeID) { + + // Cluster ApplicationBasic attributes + case MTRAttributeIDTypeClusterApplicationBasicAttributeVendorNameID: + result = @"VendorName"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeVendorIDID: + result = @"VendorID"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeApplicationNameID: + result = @"ApplicationName"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeProductIDID: + result = @"ProductID"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeApplicationID: + result = @"Application"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeStatusID: + result = @"Status"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeApplicationVersionID: + result = @"ApplicationVersion"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeAllowedVendorListID: + result = @"AllowedVendorList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterApplicationBasicAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeAccountLoginID: + + switch (attributeID) { + + // Cluster AccountLogin attributes + case MTRAttributeIDTypeClusterAccountLoginAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterAccountLoginAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeContentControlID: + + switch (attributeID) { + + // Cluster ContentControl attributes + case MTRAttributeIDTypeClusterContentControlAttributeEnabledID: + result = @"Enabled"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeOnDemandRatingsID: + result = @"OnDemandRatings"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeOnDemandRatingThresholdID: + result = @"OnDemandRatingThreshold"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeScheduledContentRatingsID: + result = @"ScheduledContentRatings"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeScheduledContentRatingThresholdID: + result = @"ScheduledContentRatingThreshold"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeScreenDailyTimeID: + result = @"ScreenDailyTime"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeRemainingScreenTimeID: + result = @"RemainingScreenTime"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeBlockUnratedID: + result = @"BlockUnrated"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterContentControlAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeContentAppObserverID: + + switch (attributeID) { + + // Cluster ContentAppObserver attributes + case MTRAttributeIDTypeClusterContentAppObserverAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterContentAppObserverAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeElectricalMeasurementID: + + switch (attributeID) { + + // Cluster ElectricalMeasurement attributes + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasurementTypeID: + result = @"MeasurementType"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageID: + result = @"DcVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageMinID: + result = @"DcVoltageMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageMaxID: + result = @"DcVoltageMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentID: + result = @"DcCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentMinID: + result = @"DcCurrentMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentMaxID: + result = @"DcCurrentMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerID: + result = @"DcPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerMinID: + result = @"DcPowerMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerMaxID: + result = @"DcPowerMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageMultiplierID: + result = @"DcVoltageMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcVoltageDivisorID: + result = @"DcVoltageDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentMultiplierID: + result = @"DcCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcCurrentDivisorID: + result = @"DcCurrentDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerMultiplierID: + result = @"DcPowerMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeDcPowerDivisorID: + result = @"DcPowerDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyID: + result = @"AcFrequency"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyMinID: + result = @"AcFrequencyMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyMaxID: + result = @"AcFrequencyMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeNeutralCurrentID: + result = @"NeutralCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeTotalActivePowerID: + result = @"TotalActivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeTotalReactivePowerID: + result = @"TotalReactivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeTotalApparentPowerID: + result = @"TotalApparentPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured1stHarmonicCurrentID: + result = @"Measured1stHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured3rdHarmonicCurrentID: + result = @"Measured3rdHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured5thHarmonicCurrentID: + result = @"Measured5thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured7thHarmonicCurrentID: + result = @"Measured7thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured9thHarmonicCurrentID: + result = @"Measured9thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasured11thHarmonicCurrentID: + result = @"Measured11thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase1stHarmonicCurrentID: + result = @"MeasuredPhase1stHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase3rdHarmonicCurrentID: + result = @"MeasuredPhase3rdHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase5thHarmonicCurrentID: + result = @"MeasuredPhase5thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase7thHarmonicCurrentID: + result = @"MeasuredPhase7thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase9thHarmonicCurrentID: + result = @"MeasuredPhase9thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeMeasuredPhase11thHarmonicCurrentID: + result = @"MeasuredPhase11thHarmonicCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyMultiplierID: + result = @"AcFrequencyMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcFrequencyDivisorID: + result = @"AcFrequencyDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerMultiplierID: + result = @"PowerMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerDivisorID: + result = @"PowerDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeHarmonicCurrentMultiplierID: + result = @"HarmonicCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePhaseHarmonicCurrentMultiplierID: + result = @"PhaseHarmonicCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousVoltageID: + result = @"InstantaneousVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousLineCurrentID: + result = @"InstantaneousLineCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousActiveCurrentID: + result = @"InstantaneousActiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousReactiveCurrentID: + result = @"InstantaneousReactiveCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeInstantaneousPowerID: + result = @"InstantaneousPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageID: + result = @"RmsVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMinID: + result = @"RmsVoltageMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMaxID: + result = @"RmsVoltageMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentID: + result = @"RmsCurrent"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMinID: + result = @"RmsCurrentMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMaxID: + result = @"RmsCurrentMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerID: + result = @"ActivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMinID: + result = @"ActivePowerMin"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMaxID: + result = @"ActivePowerMax"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactivePowerID: + result = @"ReactivePower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeApparentPowerID: + result = @"ApparentPower"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerFactorID: + result = @"PowerFactor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodID: + result = @"AverageRmsVoltageMeasurementPeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterID: + result = @"AverageRmsUnderVoltageCounter"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodID: + result = @"RmsExtremeOverVoltagePeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodID: + result = @"RmsExtremeUnderVoltagePeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagPeriodID: + result = @"RmsVoltageSagPeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodID: + result = @"RmsVoltageSwellPeriod"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcVoltageMultiplierID: + result = @"AcVoltageMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcVoltageDivisorID: + result = @"AcVoltageDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcCurrentMultiplierID: + result = @"AcCurrentMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcCurrentDivisorID: + result = @"AcCurrentDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcPowerMultiplierID: + result = @"AcPowerMultiplier"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcPowerDivisorID: + result = @"AcPowerDivisor"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeOverloadAlarmsMaskID: + result = @"OverloadAlarmsMask"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeVoltageOverloadID: + result = @"VoltageOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeCurrentOverloadID: + result = @"CurrentOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcOverloadAlarmsMaskID: + result = @"AcOverloadAlarmsMask"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcVoltageOverloadID: + result = @"AcVoltageOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcCurrentOverloadID: + result = @"AcCurrentOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcActivePowerOverloadID: + result = @"AcActivePowerOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcReactivePowerOverloadID: + result = @"AcReactivePowerOverload"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsOverVoltageID: + result = @"AverageRmsOverVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageID: + result = @"AverageRmsUnderVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltageID: + result = @"RmsExtremeOverVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltageID: + result = @"RmsExtremeUnderVoltage"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagID: + result = @"RmsVoltageSag"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellID: + result = @"RmsVoltageSwell"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeLineCurrentPhaseBID: + result = @"LineCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActiveCurrentPhaseBID: + result = @"ActiveCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactiveCurrentPhaseBID: + result = @"ReactiveCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltagePhaseBID: + result = @"RmsVoltagePhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMinPhaseBID: + result = @"RmsVoltageMinPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseBID: + result = @"RmsVoltageMaxPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentPhaseBID: + result = @"RmsCurrentPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMinPhaseBID: + result = @"RmsCurrentMinPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseBID: + result = @"RmsCurrentMaxPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerPhaseBID: + result = @"ActivePowerPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMinPhaseBID: + result = @"ActivePowerMinPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMaxPhaseBID: + result = @"ActivePowerMaxPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactivePowerPhaseBID: + result = @"ReactivePowerPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeApparentPowerPhaseBID: + result = @"ApparentPowerPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerFactorPhaseBID: + result = @"PowerFactorPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseBID: + result = @"AverageRmsVoltageMeasurementPeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseBID: + result = @"AverageRmsOverVoltageCounterPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseBID: + result = @"AverageRmsUnderVoltageCounterPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseBID: + result = @"RmsExtremeOverVoltagePeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseBID: + result = @"RmsExtremeUnderVoltagePeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseBID: + result = @"RmsVoltageSagPeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseBID: + result = @"RmsVoltageSwellPeriodPhaseB"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeLineCurrentPhaseCID: + result = @"LineCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActiveCurrentPhaseCID: + result = @"ActiveCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactiveCurrentPhaseCID: + result = @"ReactiveCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltagePhaseCID: + result = @"RmsVoltagePhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMinPhaseCID: + result = @"RmsVoltageMinPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseCID: + result = @"RmsVoltageMaxPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentPhaseCID: + result = @"RmsCurrentPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMinPhaseCID: + result = @"RmsCurrentMinPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseCID: + result = @"RmsCurrentMaxPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerPhaseCID: + result = @"ActivePowerPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMinPhaseCID: + result = @"ActivePowerMinPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeActivePowerMaxPhaseCID: + result = @"ActivePowerMaxPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeReactivePowerPhaseCID: + result = @"ReactivePowerPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeApparentPowerPhaseCID: + result = @"ApparentPowerPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributePowerFactorPhaseCID: + result = @"PowerFactorPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseCID: + result = @"AverageRmsVoltageMeasurementPeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseCID: + result = @"AverageRmsOverVoltageCounterPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseCID: + result = @"AverageRmsUnderVoltageCounterPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseCID: + result = @"RmsExtremeOverVoltagePeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseCID: + result = @"RmsExtremeUnderVoltagePeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseCID: + result = @"RmsVoltageSagPeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseCID: + result = @"RmsVoltageSwellPeriodPhaseC"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterElectricalMeasurementAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeUnitTestingID: + + switch (attributeID) { + + // Cluster UnitTesting attributes + case MTRAttributeIDTypeClusterUnitTestingAttributeBooleanID: + result = @"Boolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap8ID: + result = @"Bitmap8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap16ID: + result = @"Bitmap16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap32ID: + result = @"Bitmap32"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeBitmap64ID: + result = @"Bitmap64"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt8uID: + result = @"Int8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt16uID: + result = @"Int16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt24uID: + result = @"Int24u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt32uID: + result = @"Int32u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt40uID: + result = @"Int40u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt48uID: + result = @"Int48u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt56uID: + result = @"Int56u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt64uID: + result = @"Int64u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt8sID: + result = @"Int8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt16sID: + result = @"Int16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt24sID: + result = @"Int24s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt32sID: + result = @"Int32s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt40sID: + result = @"Int40s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt48sID: + result = @"Int48s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt56sID: + result = @"Int56s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeInt64sID: + result = @"Int64s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEnum8ID: + result = @"Enum8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEnum16ID: + result = @"Enum16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeFloatSingleID: + result = @"FloatSingle"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeFloatDoubleID: + result = @"FloatDouble"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeOctetStringID: + result = @"OctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListInt8uID: + result = @"ListInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListOctetStringID: + result = @"ListOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListStructOctetStringID: + result = @"ListStructOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeLongOctetStringID: + result = @"LongOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeCharStringID: + result = @"CharString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeLongCharStringID: + result = @"LongCharString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEpochUsID: + result = @"EpochUs"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEpochSID: + result = @"EpochS"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeVendorIdID: + result = @"VendorId"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListNullablesAndOptionalsStructID: + result = @"ListNullablesAndOptionalsStruct"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEnumAttrID: + result = @"EnumAttr"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeStructAttrID: + result = @"StructAttr"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt8uID: + result = @"RangeRestrictedInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt8sID: + result = @"RangeRestrictedInt8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt16uID: + result = @"RangeRestrictedInt16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeRangeRestrictedInt16sID: + result = @"RangeRestrictedInt16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListLongOctetStringID: + result = @"ListLongOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeListFabricScopedID: + result = @"ListFabricScoped"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeTimedWriteBooleanID: + result = @"TimedWriteBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeGeneralErrorBooleanID: + result = @"GeneralErrorBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeClusterErrorBooleanID: + result = @"ClusterErrorBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeUnsupportedID: + result = @"Unsupported"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBooleanID: + result = @"NullableBoolean"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap8ID: + result = @"NullableBitmap8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap16ID: + result = @"NullableBitmap16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap32ID: + result = @"NullableBitmap32"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap64ID: + result = @"NullableBitmap64"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt8uID: + result = @"NullableInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt16uID: + result = @"NullableInt16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt24uID: + result = @"NullableInt24u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt32uID: + result = @"NullableInt32u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt40uID: + result = @"NullableInt40u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt48uID: + result = @"NullableInt48u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt56uID: + result = @"NullableInt56u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt64uID: + result = @"NullableInt64u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt8sID: + result = @"NullableInt8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt16sID: + result = @"NullableInt16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt24sID: + result = @"NullableInt24s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt32sID: + result = @"NullableInt32s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt40sID: + result = @"NullableInt40s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt48sID: + result = @"NullableInt48s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt56sID: + result = @"NullableInt56s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableInt64sID: + result = @"NullableInt64s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableEnum8ID: + result = @"NullableEnum8"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableEnum16ID: + result = @"NullableEnum16"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableFloatSingleID: + result = @"NullableFloatSingle"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableFloatDoubleID: + result = @"NullableFloatDouble"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableOctetStringID: + result = @"NullableOctetString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableCharStringID: + result = @"NullableCharString"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableEnumAttrID: + result = @"NullableEnumAttr"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableStructID: + result = @"NullableStruct"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt8uID: + result = @"NullableRangeRestrictedInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt8sID: + result = @"NullableRangeRestrictedInt8s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt16uID: + result = @"NullableRangeRestrictedInt16u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt16sID: + result = @"NullableRangeRestrictedInt16s"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeWriteOnlyInt8uID: + result = @"WriteOnlyInt8u"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeMeiInt8uID: + result = @"MeiInt8u"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + case MTRClusterIDTypeSampleMEIID: + + switch (attributeID) { + + // Cluster SampleMEI attributes + case MTRAttributeIDTypeClusterSampleMEIAttributeFlipFlopID: + result = @"FlipFlop"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeGeneratedCommandListID: + result = @"GeneratedCommandList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeAcceptedCommandListID: + result = @"AcceptedCommandList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeEventListID: + result = @"EventList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeAttributeListID: + result = @"AttributeList"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeFeatureMapID: + result = @"FeatureMap"; + break; + + case MTRAttributeIDTypeClusterSampleMEIAttributeClusterRevisionID: + result = @"ClusterRevision"; + break; + + default: + result = [NSString stringWithFormat:@"", attributeID]; + break; + } + + default: + result = [NSString stringWithFormat:@"", clusterID]; + break; + } + + return result; +} + +// @end diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm index 991f6fb6170e48..46427cba7fab3b 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm @@ -92,6 +92,7 @@ { 0x00000305, DeviceTypeClass::Simple, "Matter Pressure Sensor" }, { 0x00000306, DeviceTypeClass::Simple, "Matter Flow Sensor" }, { 0x00000307, DeviceTypeClass::Simple, "Matter Humidity Sensor" }, + { 0x0000050C, DeviceTypeClass::Simple, "Matter EVSE" }, { 0x00000510, DeviceTypeClass::Utility, "Matter Electrical Sensor" }, { 0x00000840, DeviceTypeClass::Simple, "Matter Control Bridge" }, { 0x00000850, DeviceTypeClass::Simple, "Matter On/Off Sensor" }, diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 52cd52b0b9599b..5c735e19329ad8 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -249,6 +249,8 @@ 88EBF8CE27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88EBF8CF27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */; }; 88EBF8D027FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CD27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h */; }; + 93B2CF9A2B56E45C00E4D187 /* MTRClusterNames.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B2CF992B56E45C00E4D187 /* MTRClusterNames.mm */; }; + 93E610AA2B626E290077F02A /* MTRClusterNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E610A92B626E290077F02A /* MTRClusterNames.h */; settings = {ATTRIBUTES = (Public, ); }; }; 991DC0842475F45400C13860 /* MTRDeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC0822475F45400C13860 /* MTRDeviceController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 991DC0892475F47D00C13860 /* MTRDeviceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 991DC0872475F47D00C13860 /* MTRDeviceController.mm */; }; 991DC08B247704DC00C13860 /* MTRLogging_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC08A247704DC00C13860 /* MTRLogging_Internal.h */; }; @@ -640,6 +642,8 @@ 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceAttestationDelegate.h; sourceTree = ""; }; 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceAttestationDelegateBridge.mm; sourceTree = ""; }; 88EBF8CD27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceAttestationDelegateBridge.h; sourceTree = ""; }; + 93B2CF992B56E45C00E4D187 /* MTRClusterNames.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRClusterNames.mm; sourceTree = ""; }; + 93E610A92B626E290077F02A /* MTRClusterNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRClusterNames.h; sourceTree = ""; }; 991DC0822475F45400C13860 /* MTRDeviceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDeviceController.h; sourceTree = ""; }; 991DC0872475F47D00C13860 /* MTRDeviceController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceController.mm; sourceTree = ""; }; 991DC08A247704DC00C13860 /* MTRLogging_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRLogging_Internal.h; sourceTree = ""; }; @@ -1036,6 +1040,7 @@ 7596A83D28751220004DAE0E /* MTRBaseClusters_Internal.h */, 1EC4CE5925CC26E900D7304F /* MTRBaseClusters.mm */, D4772A45285AE98300383630 /* MTRClusterConstants.h */, + 93B2CF992B56E45C00E4D187 /* MTRClusterNames.mm */, 7596A85428788557004DAE0E /* MTRClusters.h */, 3D843715294979230070D20A /* MTRClusters_Internal.h */, 7596A85228788557004DAE0E /* MTRClusters.mm */, @@ -1215,6 +1220,7 @@ 1ED276E326C5832500547A89 /* MTRCluster.h */, 7596A84E2877E6A9004DAE0E /* MTRCluster_Internal.h */, 1ED276E126C5812A00547A89 /* MTRCluster.mm */, + 93E610A92B626E290077F02A /* MTRClusterNames.h */, 5ACDDD7927CD129700EFD68A /* MTRClusterStateCacheContainer.h */, 5ACDDD7B27CD14AF00EFD68A /* MTRClusterStateCacheContainer_Internal.h */, 5ACDDD7C27CD16D200EFD68A /* MTRClusterStateCacheContainer.mm */, @@ -1561,6 +1567,7 @@ B4FCD56A2B5EDBD300832859 /* MTRDiagnosticLogsType.h in Headers */, 5A6FEC9A27B5C89300F25F42 /* MTRDeviceControllerXPCConnection.h in Headers */, 5129BCFD26A9EE3300122DDF /* MTRError.h in Headers */, + 93E610AA2B626E290077F02A /* MTRClusterNames.h in Headers */, 2C8C8FC1253E0C2100797F05 /* MTRStorage.h in Headers */, AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */, B2E0D7B5245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.h in Headers */, @@ -1831,6 +1838,7 @@ 515C1C6F284F9FFB00A48F0C /* MTRFramework.mm in Sources */, 51029DF6293AA6100087AFB0 /* MTROperationalCertificateIssuer.mm in Sources */, 27A53C1827FBC6920053F131 /* MTRAttestationTrustStoreBridge.mm in Sources */, + 93B2CF9A2B56E45C00E4D187 /* MTRClusterNames.mm in Sources */, 998F287126D56940001846C6 /* MTRP256KeypairBridge.mm in Sources */, 51D0B1412B61B3A4006E3511 /* MTRServerCluster.mm in Sources */, 5136661428067D550025EDAE /* MTRDeviceControllerFactory.mm in Sources */, diff --git a/src/lib/dnssd/BUILD.gn b/src/lib/dnssd/BUILD.gn index 295be7d51a191d..1561a395aa28f9 100644 --- a/src/lib/dnssd/BUILD.gn +++ b/src/lib/dnssd/BUILD.gn @@ -27,7 +27,7 @@ static_library("dnssd") { "${chip_root}/src/crypto", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", - "${chip_root}/src/messaging:messaging_mrp_config", + "${chip_root}/src/messaging:configurations", ] sources = [ @@ -53,6 +53,7 @@ static_library("dnssd") { "ActiveResolveAttempts.cpp", "ActiveResolveAttempts.h", "Advertiser_ImplMinimalMdns.cpp", + "Advertiser_ImplMinimalMdnsAllocator.h", "IncrementalResolve.cpp", "IncrementalResolve.h", "MinimalMdnsServer.cpp", diff --git a/src/lib/shell/streamer_cc13x2_26x2.cpp b/src/lib/shell/streamer_cc13x2_26x2.cpp deleted file mode 100644 index f6d256409dc492..00000000000000 --- a/src/lib/shell/streamer_cc13x2_26x2.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Source implementation of an input / output stream for cc13x2_26x2 targets - */ - -#include "streamer.h" -#include -#include -#include -#include - -#include "ti_drivers_config.h" - -#include - -namespace chip { -namespace Shell { - -#ifndef SHELL_STREAMER_APP_SPECIFIC - -UART_Handle sStreamUartHandle = NULL; - -#if !MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED -extern "C" int cc13x2_26x2LogInit(void) -{ - return 0; -} - -extern "C" void cc13x2_26x2VLog(const char * msg, va_list v) -{ - if (NULL != sStreamUartHandle) - { - static char sDebugUartBuffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - size_t ret; - - ret = vsnprintf(sDebugUartBuffer, sizeof(sDebugUartBuffer), msg, v); - if (0 < ret) - { - // PuTTY likes \r\n - size_t len = (ret + 2U) < sizeof(sDebugUartBuffer) ? (ret + 2) : sizeof(sDebugUartBuffer); - sDebugUartBuffer[len - 2] = '\r'; - sDebugUartBuffer[len - 1] = '\n'; - - UART_write(sStreamUartHandle, sDebugUartBuffer, len); - } - } -} -#endif // !MATTER_CC13X2_26X2_PLATFORM_LOG_ENABLED - -int streamer_cc13x2_26x2_init(streamer_t * streamer) -{ - UART_Params uartParams; - - UART_init(); - - UART_Params_init(&uartParams); - // Most params can be default because we only send data, we don't receive - uartParams.baudRate = 115200; - // unclear why the UART driver sticks in writing sometimes - uartParams.writeTimeout = 10000; // ticks - // Immediate return from the read function - // uartParams.readTimeout = 0; // ticks - - sStreamUartHandle = UART_open(CONFIG_UART_STREAMER, &uartParams); - return 0; -} - -ssize_t streamer_cc13x2_26x2_read(streamer_t * streamer, char * buf, size_t len) -{ - (void) streamer; - return UART_read(sStreamUartHandle, buf, len); -} - -ssize_t streamer_cc13x2_26x2_write(streamer_t * streamer, const char * buf, size_t len) -{ - (void) streamer; - return UART_write(sStreamUartHandle, buf, len); -} - -static streamer_t streamer_cc13x2_26x2 = { - .init_cb = streamer_cc13x2_26x2_init, - .read_cb = streamer_cc13x2_26x2_read, - .write_cb = streamer_cc13x2_26x2_write, -}; - -streamer_t * streamer_get() -{ - return &streamer_cc13x2_26x2; -} - -#endif // #ifndef SHELL_STREAMER_APP_SPECIFIC - -} // namespace Shell -} // namespace chip diff --git a/src/messaging/BUILD.gn b/src/messaging/BUILD.gn index b2c053f70a28c6..a170d625111a06 100644 --- a/src/messaging/BUILD.gn +++ b/src/messaging/BUILD.gn @@ -33,10 +33,16 @@ if (chip_config_resolve_peer_on_first_transmit_failure != "") { defines += [ "CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE=${chip_config_resolve_peer_on_first_transmit_failure}" ] } -source_set("messaging_mrp_config") { - sources = [ "ReliableMessageProtocolConfig.h" ] +source_set("configurations") { + sources = [ + "ReliableMessageProtocolConfig.h", + "SessionParameters.h", + ] - public_deps = [ "${chip_root}/src/system" ] + public_deps = [ + "${chip_root}/src/lib/core", + "${chip_root}/src/system", + ] } static_library("messaging") { @@ -67,7 +73,7 @@ static_library("messaging") { cflags = [ "-Wconversion" ] public_deps = [ - ":messaging_mrp_config", + ":configurations", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/crypto", "${chip_root}/src/inet", diff --git a/src/protocols/secure_channel/SessionParameters.h b/src/messaging/SessionParameters.h similarity index 100% rename from src/protocols/secure_channel/SessionParameters.h rename to src/messaging/SessionParameters.h diff --git a/src/platform/ESP32/BUILD.gn b/src/platform/ESP32/BUILD.gn index c5b59add8e9e34..768f6a25ba0e64 100644 --- a/src/platform/ESP32/BUILD.gn +++ b/src/platform/ESP32/BUILD.gn @@ -128,6 +128,9 @@ static_library("ESP32") { "WiFiDnssdImpl.h", ] } + if (chip_mdns == "minimal") { + sources += [ "ESP32EndpointQueueFilter.h" ] + } if (chip_enable_route_hook) { sources += [ "route_hook/ESP32RouteHook.c", diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index 245f908d434adf..c2aa892ac04b13 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -95,3 +95,7 @@ #endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC #endif // CONFIG_ENABLE_ICD_SERVER + +#ifdef CONFIG_CHIP_ENABLE_BDX_LOG_TRANSFER +#define CHIP_CONFIG_ENABLE_BDX_LOG_TRANSFER 1 +#endif // CONFIG_CHIP_ENABLE_BDX_LOG_TRANSFER diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index e52319b55bb365..8fb52e7bb71629 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1107,6 +1108,35 @@ void ConnectivityManagerImpl::OnStationIPv6AddressAvailable(const ip_event_got_i event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; PlatformMgr().PostEventOrDie(&event); + +#if CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER + uint8_t station_mac[6]; + if (esp_wifi_get_mac(WIFI_IF_STA, station_mac) == ESP_OK) + { + static chip::Inet::ESP32EndpointQueueFilter sEndpointQueueFilter; + char station_mac_str[12]; + for (size_t i = 0; i < 6; ++i) + { + uint8_t dig1 = (station_mac[i] & 0xF0) >> 4; + uint8_t dig2 = station_mac[i] & 0x0F; + station_mac_str[2 * i] = dig1 > 9 ? ('A' + dig1 - 0xA) : ('0' + dig1); + station_mac_str[2 * i + 1] = dig2 > 9 ? ('A' + dig2 - 0xA) : ('0' + dig2); + } + if (sEndpointQueueFilter.SetMdnsHostName(chip::CharSpan(station_mac_str)) == CHIP_NO_ERROR) + { + chip::Inet::UDPEndPointImpl::SetQueueFilter(&sEndpointQueueFilter); + } + else + { + ChipLogError(DeviceLayer, "Failed to set mDNS hostname for endpoint queue filter"); + } + } + else + { + ChipLogError(DeviceLayer, "Failed to get the MAC address of station netif"); + } +#endif // CONFIG_ENABLE_ENDPOINT_QUEUE_FILTER + #if CONFIG_ENABLE_ROUTE_HOOK esp_route_hook_init(esp_netif_get_handle_from_ifkey(ESP32Utils::kDefaultWiFiStationNetifKey)); #endif diff --git a/src/platform/ESP32/ESP32EndpointQueueFilter.h b/src/platform/ESP32/ESP32EndpointQueueFilter.h new file mode 100644 index 00000000000000..e7d154dcf458af --- /dev/null +++ b/src/platform/ESP32/ESP32EndpointQueueFilter.h @@ -0,0 +1,129 @@ +/* + * + * 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. + */ + +#pragma once + +#include +#include +#include + +namespace chip { +namespace Inet { + +class ESP32EndpointQueueFilter : public EndpointQueueFilter +{ +public: + CHIP_ERROR SetMdnsHostName(const chip::CharSpan & hostName) + { + ReturnErrorCodeIf(hostName.size() != sizeof(mHostNameBuffer), CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!IsValidMdnsHostName(hostName), CHIP_ERROR_INVALID_ARGUMENT); + memcpy(mHostNameBuffer, hostName.data(), hostName.size()); + return CHIP_NO_ERROR; + } + + FilterOutcome FilterBeforeEnqueue(const void * endpoint, const IPPacketInfo & pktInfo, + const chip::System::PacketBufferHandle & pktPayload) override + { + if (!IsMdnsBroadcastPacket(pktInfo)) + { + return FilterOutcome::kAllowPacket; + } + // Drop the mDNS packets which don't contain 'matter' or ''. + const uint8_t matterBytes[] = { 'm', 'a', 't', 't', 'e', 'r' }; + if (PayloadContains(pktPayload, ByteSpan(matterBytes)) || PayloadContainsHostNameCaseInsensitive(pktPayload)) + { + return FilterOutcome::kAllowPacket; + } + return FilterOutcome::kDropPacket; + } + + FilterOutcome FilterAfterDequeue(const void * endpoint, const IPPacketInfo & pktInfo, + const chip::System::PacketBufferHandle & pktPayload) override + { + return FilterOutcome::kAllowPacket; + } + +private: + // TODO: Add unit tests for these static functions + static bool IsMdnsBroadcastPacket(const IPPacketInfo & pktInfo) + { + if (pktInfo.DestPort == 5353) + { +#if INET_CONFIG_ENABLE_IPV4 + ip_addr_t mdnsIPv4BroadcastAddr = IPADDR4_INIT_BYTES(224, 0, 0, 251); + if (pktInfo.DestAddress == chip::Inet::IPAddress(mdnsIPv4BroadcastAddr)) + { + return true; + } +#endif + ip_addr_t mdnsIPv6BroadcastAddr = IPADDR6_INIT_HOST(0xFF020000, 0, 0, 0xFB); + if (pktInfo.DestAddress == chip::Inet::IPAddress(mdnsIPv6BroadcastAddr)) + { + return true; + } + } + return false; + } + + static bool PayloadContains(const chip::System::PacketBufferHandle & payload, const chip::ByteSpan & byteSpan) + { + if (payload->HasChainedBuffer() || payload->TotalLength() < byteSpan.size()) + { + return false; + } + for (size_t i = 0; i <= payload->TotalLength() - byteSpan.size(); ++i) + { + if (memcmp(payload->Start() + i, byteSpan.data(), byteSpan.size()) == 0) + { + return true; + } + } + return false; + } + + bool PayloadContainsHostNameCaseInsensitive(const chip::System::PacketBufferHandle & payload) + { + uint8_t hostNameLowerCase[12]; + memcpy(hostNameLowerCase, mHostNameBuffer, sizeof(mHostNameBuffer)); + for (size_t i = 0; i < sizeof(hostNameLowerCase); ++i) + { + if (hostNameLowerCase[i] <= 'F' && hostNameLowerCase[i] >= 'A') + { + hostNameLowerCase[i] = 'a' + hostNameLowerCase[i] - 'A'; + } + } + return PayloadContains(payload, ByteSpan(mHostNameBuffer)) || PayloadContains(payload, ByteSpan(hostNameLowerCase)); + } + + static bool IsValidMdnsHostName(const chip::CharSpan & hostName) + { + for (size_t i = 0; i < hostName.size(); ++i) + { + char ch_data = *(hostName.data() + i); + if (!((ch_data >= '0' && ch_data <= '9') || (ch_data >= 'A' && ch_data <= 'F'))) + { + return false; + } + } + return true; + } + + uint8_t mHostNameBuffer[12] = { 0 }; +}; + +} // namespace Inet +} // namespace chip diff --git a/src/platform/Linux/BUILD.gn b/src/platform/Linux/BUILD.gn index 635fd446eb941e..6fca28efb0ae3a 100644 --- a/src/platform/Linux/BUILD.gn +++ b/src/platform/Linux/BUILD.gn @@ -97,6 +97,8 @@ static_library("Linux") { "bluez/BluezConnection.h", "bluez/BluezEndpoint.cpp", "bluez/BluezEndpoint.h", + "bluez/BluezObjectIterator.h", + "bluez/BluezObjectList.h", "bluez/ChipDeviceScanner.cpp", "bluez/ChipDeviceScanner.h", "bluez/Types.h", diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 12aadb24400691..fa3a50974f6a50 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -118,22 +118,6 @@ // ========== Platform-specific Configuration Overrides ========= -#ifndef CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY -#define CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY (configTIMER_TASK_PRIORITY - 1) -#endif // CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY - -#ifndef CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY -#define CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY (CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY - 1) -#endif // CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - -#ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY -#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY (CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - 1) -#endif // CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY - -#ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE -#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE 1536 -#endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE - #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (6 * 1024) #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE diff --git a/src/platform/silabs/ConfigurationManagerImpl.h b/src/platform/silabs/ConfigurationManagerImpl.h index c025f51de40041..f34e37ed91bb52 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.h +++ b/src/platform/silabs/ConfigurationManagerImpl.h @@ -73,7 +73,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp void RunConfigUnitTest(void) override; // ===== Private members reserved for use by this class only. - uint32_t rebootCause; static void DoFactoryReset(intptr_t arg); }; diff --git a/src/platform/silabs/efr32/ConfigurationManagerImpl.cpp b/src/platform/silabs/efr32/ConfigurationManagerImpl.cpp index ed0aaad8e1d61f..14da9b5d9bb8c2 100644 --- a/src/platform/silabs/efr32/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/efr32/ConfigurationManagerImpl.cpp @@ -22,15 +22,12 @@ * for EFR32 platforms using the Silicon Labs SDK. */ /* this file behaves like a config.h, comes first */ -#include - -#include - #include #include +#include +#include #include - -#include "em_rmu.h" +#include #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION #include "wfx_host_events.h" @@ -55,12 +52,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init() err = Internal::GenericConfigurationManagerImpl::Init(); SuccessOrExit(err); - // TODO: Initialize the global GroupKeyStore object here (#1626) - IncreaseBootCount(); - rebootCause = RMU_ResetCauseGet(); - RMU_ResetCauseClear(); - err = CHIP_NO_ERROR; exit: @@ -99,6 +91,8 @@ CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) { // rebootCause is obtained at bootup. BootReasonType matterBootCause; + uint32_t rebootCause = Silabs::GetPlatform().GetRebootCause(); + #if defined(_SILICON_LABS_32B_SERIES_1) if (rebootCause & RMU_RSTCAUSE_PORST || rebootCause & RMU_RSTCAUSE_EXTRST) // PowerOn or External pin reset { diff --git a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp index 49f8ed48b17ad9..dda1b7e0e19dac 100644 --- a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp +++ b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp @@ -17,6 +17,7 @@ #include +#include "em_rmu.h" #include "sl_system_kernel.h" #ifdef ENABLE_WSTK_LEDS @@ -69,6 +70,10 @@ CHIP_ERROR SilabsPlatform::Init(void) { sl_system_init(); + mRebootCause = RMU_ResetCauseGet(); + // Clear register so it does accumualate the causes of each reset + RMU_ResetCauseClear(); + #if CHIP_ENABLE_OPENTHREAD sl_ot_sys_init(); #endif diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatform.h b/src/platform/silabs/platformAbstraction/SilabsPlatform.h index 4e5e4b2ba57396..4c42a79996b3f0 100644 --- a/src/platform/silabs/platformAbstraction/SilabsPlatform.h +++ b/src/platform/silabs/platformAbstraction/SilabsPlatform.h @@ -49,6 +49,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase #endif inline void SetButtonsCb(SilabsButtonCb callback) override { mButtonCallback = callback; } + inline uint32_t GetRebootCause() { return mRebootCause; } static SilabsButtonCb mButtonCallback; @@ -64,6 +65,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase SilabsPlatform(){}; virtual ~SilabsPlatform() = default; + uint32_t mRebootCause = 0; static SilabsPlatform sSilabsPlatformAbstractionManager; }; diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h index f5630ddbb0c0b3..fa387228ab2885 100644 --- a/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h +++ b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h @@ -35,6 +35,7 @@ class SilabsPlatformAbstractionBase virtual CHIP_ERROR InitLCD() { return CHIP_ERROR_NOT_IMPLEMENTED; } virtual CHIP_ERROR SetGPIO(uint32_t port, uint32_t pin, bool state) { return CHIP_ERROR_NOT_IMPLEMENTED; } virtual bool GetGPIO(uint32_t port, uint32_t pin) { return false; } + virtual uint32_t GetRebootCause() = 0; // Scheduler virtual void StartScheduler(void) = 0; diff --git a/src/protocols/secure_channel/CASEServer.cpp b/src/protocols/secure_channel/CASEServer.cpp index d701d8c568c584..2ad196a31b9461 100644 --- a/src/protocols/secure_channel/CASEServer.cpp +++ b/src/protocols/secure_channel/CASEServer.cpp @@ -183,6 +183,7 @@ void CASEServer::OnSessionEstablishmentError(CHIP_ERROR err) MATTER_TRACE_SCOPE("OnSessionEstablishmentError", "CASEServer"); ChipLogError(Inet, "CASE Session establishment failed: %" CHIP_ERROR_FORMAT, err.Format()); + MATTER_TRACE_SCOPE("CASEFail", "CASESession"); PrepareForSessionEstablishment(); } diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 8573d1565686fe..ee8feaefb5f93d 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -37,11 +37,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -552,6 +552,7 @@ void CASESession::OnResponseTimeout(ExchangeContext * ec) VerifyOrReturn(mExchangeCtxt == ec, ChipLogError(SecureChannel, "CASESession::OnResponseTimeout exchange doesn't match")); ChipLogError(SecureChannel, "CASESession timed out while waiting for a response from the peer. Current state was %u", to_underlying(mState)); + MATTER_TRACE_COUNTER("CASETimeout"); // Discard the exchange so that Clear() doesn't try aborting it. The // exchange will handle that. DiscardExchange(); @@ -844,6 +845,7 @@ CHIP_ERROR CASESession::HandleSigma1(System::PacketBufferHandle && msg) ByteSpan initiatorRandom; ChipLogProgress(SecureChannel, "Received Sigma1 msg"); + MATTER_TRACE_COUNTER("Sigma1"); bool sessionResumptionRequested = false; ByteSpan resumptionId; @@ -1100,6 +1102,7 @@ CHIP_ERROR CASESession::SendSigma2() mState = State::kSentSigma2; ChipLogProgress(SecureChannel, "Sent Sigma2 msg"); + MATTER_TRACE_COUNTER("Sigma2"); return CHIP_NO_ERROR; } @@ -1116,6 +1119,7 @@ CHIP_ERROR CASESession::HandleSigma2Resume(System::PacketBufferHandle && msg) uint32_t decodeTagIdSeq = 0; ChipLogDetail(SecureChannel, "Received Sigma2Resume msg"); + MATTER_TRACE_COUNTER("Sigma2Resume"); uint8_t sigma2ResumeMIC[CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES]; @@ -1585,6 +1589,7 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) uint8_t msg_salt[kIPKSize + kSHA256_Hash_Length]; ChipLogProgress(SecureChannel, "Received Sigma3 msg"); + MATTER_TRACE_COUNTER("Sigma3"); auto helper = WorkHelper::Create(*this, &HandleSigma3b, &CASESession::HandleSigma3c); VerifyOrExit(helper, err = CHIP_ERROR_NO_MEMORY); diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index 67da1d103ebf83..95fb9c89c7432e 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -39,9 +39,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -251,6 +251,7 @@ void PASESession::OnResponseTimeout(ExchangeContext * ec) // If we were waiting for something, mNextExpectedMsg had better have a value. ChipLogError(SecureChannel, "PASESession timed out while waiting for a response from the peer. Expected message type was %u", to_underlying(mNextExpectedMsg.Value())); + MATTER_TRACE_COUNTER("PASETimeout"); // Discard the exchange so that Clear() doesn't try closing it. The // exchange will handle that. DiscardExchange(); @@ -572,6 +573,7 @@ CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && ms size_t verifier_len = kMAX_Hash_Length; ChipLogDetail(SecureChannel, "Received spake2p msg1"); + MATTER_TRACE_SCOPE("Pake1", "PASESession"); System::PacketBufferTLVReader tlvReader; TLV::TLVType containerType = TLV::kTLVType_Structure; @@ -620,6 +622,7 @@ CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && ms } ChipLogDetail(SecureChannel, "Sent spake2p msg2"); + MATTER_TRACE_COUNTER("Pake2"); exit: @@ -711,6 +714,7 @@ CHIP_ERROR PASESession::HandleMsg3(System::PacketBufferHandle && msg) CHIP_ERROR err = CHIP_NO_ERROR; ChipLogDetail(SecureChannel, "Received spake2p msg3"); + MATTER_TRACE_COUNTER("Pake3"); mNextExpectedMsg.ClearValue(); @@ -871,6 +875,7 @@ CHIP_ERROR PASESession::OnMessageReceived(ExchangeContext * exchange, const Payl DiscardExchange(); Clear(); ChipLogError(SecureChannel, "Failed during PASE session setup: %" CHIP_ERROR_FORMAT, err.Format()); + MATTER_TRACE_COUNTER("PASEFail"); // Do this last in case the delegate frees us. NotifySessionEstablishmentError(err); } diff --git a/src/protocols/secure_channel/PairingSession.h b/src/protocols/secure_channel/PairingSession.h index ffbb6d9966485d..e8849822de57e1 100644 --- a/src/protocols/secure_channel/PairingSession.h +++ b/src/protocols/secure_channel/PairingSession.h @@ -28,9 +28,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/src/tracing/backend.h b/src/tracing/backend.h index 7e04490e333ff7..3d8bec8ada501f 100644 --- a/src/tracing/backend.h +++ b/src/tracing/backend.h @@ -63,6 +63,7 @@ class Backend : public ::chip::IntrusiveListNodeBase<> /// Trace a zero-sized event virtual void TraceInstant(const char * label, const char * group) {} + virtual void TraceCounter(const char * label) {} virtual void LogMessageSend(MessageSendInfo &) { TraceInstant("MessageSent", "Messaging"); } virtual void LogMessageReceived(MessageReceivedInfo &) { TraceInstant("MessageReceived", "Messaging"); } diff --git a/src/tracing/esp32_trace/BUILD.gn b/src/tracing/esp32_trace/BUILD.gn index 7548894ab072ce..294cf1f5dc160b 100644 --- a/src/tracing/esp32_trace/BUILD.gn +++ b/src/tracing/esp32_trace/BUILD.gn @@ -29,6 +29,8 @@ static_library("backend") { output_dir = "${root_out_dir}/lib" sources = [ + "counter.cpp", + "counter.h", "esp32_tracing.cpp", "esp32_tracing.h", ] @@ -43,7 +45,10 @@ static_library("backend") { "${chip_root}/src/system", ] } - public_deps = [ "${chip_root}/src/tracing" ] + public_deps = [ + "${chip_root}/src/lib/core", + "${chip_root}/src/tracing", + ] } source_set("esp32_trace_tracing") { diff --git a/src/tracing/esp32_trace/counter.cpp b/src/tracing/esp32_trace/counter.cpp new file mode 100644 index 00000000000000..0b315a87007484 --- /dev/null +++ b/src/tracing/esp32_trace/counter.cpp @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2024 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 + +using namespace chip; + +namespace Insights { + +// This is a one time allocation for counters. It is not supposed to be freed. +ESPInsightsCounter * ESPInsightsCounter::mHead = nullptr; + +ESPInsightsCounter * ESPInsightsCounter::GetInstance(const char * label) +{ + ESPInsightsCounter * current = mHead; + + while (current != nullptr) + { + if (strcmp(current->label, label) == 0) + { + current->instanceCount++; + return current; + } + current = current->mNext; + } + + // Allocate a new instance if counter is not present in the list. + void * ptr = Platform::MemoryAlloc(sizeof(ESPInsightsCounter)); + VerifyOrDie(ptr != nullptr); + + ESPInsightsCounter * newInstance = new (ptr) ESPInsightsCounter(label); + newInstance->mNext = mHead; + mHead = newInstance; + + return newInstance; +} + +int ESPInsightsCounter::GetInstanceCount() const +{ + return instanceCount; +} + +void ESPInsightsCounter::ReportMetrics() +{ + if (!registered) + { + esp_diag_metrics_register("SYS_CNT" /* Tag of metrics */, label /* Unique key 8 */, + label /* label displayed on dashboard */, "insights.cnt" /* hierarchical path */, + ESP_DIAG_DATA_TYPE_UINT /* data_type */); + registered = true; + } + ESP_LOGI("mtr", "Label = %s Count = %d", label, instanceCount); + esp_diag_metrics_add_uint(label, instanceCount); +} + +} // namespace Insights diff --git a/src/tracing/esp32_trace/counter.h b/src/tracing/esp32_trace/counter.h new file mode 100644 index 00000000000000..bfa6205c341a13 --- /dev/null +++ b/src/tracing/esp32_trace/counter.h @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2024 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 +#include + +namespace Insights { + +/* + * + * This class is used to monotonically increment the counters as per the label of the counter macro + * 'MATTER_TRACE_COUNTER(label)' and report the metrics to esp-insights. + * As per the label of the counter macro, it adds the counter in the linked list with the name label if not + * present and returns the same instance and increments the value if the counter is already present + * in the list. + */ + +class ESPInsightsCounter +{ +private: + static ESPInsightsCounter * mHead; // head of the counter list + const char * label; // unique key + int instanceCount; + ESPInsightsCounter * mNext; // pointer to point to the next entry in the list + bool registered = false; + + ESPInsightsCounter(const char * labelParam) : label(labelParam), instanceCount(1), mNext(nullptr) {} + +public: + static ESPInsightsCounter * GetInstance(const char * label); + + int GetInstanceCount() const; + + void ReportMetrics(); +}; + +} // namespace Insights diff --git a/src/tracing/esp32_trace/esp32_tracing.cpp b/src/tracing/esp32_trace/esp32_tracing.cpp index 7a1313089703f2..7937772606eec0 100644 --- a/src/tracing/esp32_trace/esp32_tracing.cpp +++ b/src/tracing/esp32_trace/esp32_tracing.cpp @@ -16,13 +16,14 @@ * limitations under the License. */ -#include "esp32_tracing.h" #include #include #include #include #include #include +#include +#include namespace chip { namespace Tracing { @@ -148,6 +149,10 @@ void ESP32Backend::LogNodeDiscovered(NodeDiscoveredInfo & info) {} void ESP32Backend::LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo & info) {} +void ESP32Backend::TraceCounter(const char * label) +{ + ::Insights::ESPInsightsCounter::GetInstance(label)->ReportMetrics(); +} void ESP32Backend::TraceBegin(const char * label, const char * group) { HashValue hashValue = MurmurHash(group); diff --git a/src/tracing/esp32_trace/esp32_tracing.h b/src/tracing/esp32_trace/esp32_tracing.h index 7fe783d817d8d8..6d9a277e06561d 100644 --- a/src/tracing/esp32_trace/esp32_tracing.h +++ b/src/tracing/esp32_trace/esp32_tracing.h @@ -28,6 +28,8 @@ class ESP32Backend : public ::chip::Tracing::Backend /// Trace a zero-sized event void TraceInstant(const char * label, const char * group) override; + void TraceCounter(const char * label) override; + void LogMessageSend(MessageSendInfo &) override; void LogMessageReceived(MessageReceivedInfo &) override; diff --git a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h index 4d8a8a2a214525..b95c20754237a1 100644 --- a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h +++ b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h @@ -28,6 +28,7 @@ #define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) #define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) #define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) +#define MATTER_TRACE_COUNTER(label) ::chip::Tracing::Internal::Counter(label) namespace chip { namespace Tracing { diff --git a/src/tracing/json/json_tracing.cpp b/src/tracing/json/json_tracing.cpp index 6c651b3190b485..af66e12a61a50b 100644 --- a/src/tracing/json/json_tracing.cpp +++ b/src/tracing/json/json_tracing.cpp @@ -23,9 +23,8 @@ #include #include #include -#include - #include +#include #include @@ -276,6 +275,26 @@ void JsonBackend::TraceInstant(const char * label, const char * group) OutputValue(value); } +void JsonBackend::TraceCounter(const char * label) +{ + std::string counterId = std::string(label); + if (mCounters.find(counterId) == mCounters.end()) + { + mCounters[counterId] = 1; + } + else + { + mCounters[counterId]++; + } + ::Json::Value value; + value["event"] = "TraceCounter"; + value["label"] = label; + value["count"] = mCounters[counterId]; + + // Output the counter event + OutputValue(value); +} + void JsonBackend::LogMessageSend(MessageSendInfo & info) { ::Json::Value value; diff --git a/src/tracing/json/json_tracing.h b/src/tracing/json/json_tracing.h index 74451b705b73e0..302c4bd5b5a485 100644 --- a/src/tracing/json/json_tracing.h +++ b/src/tracing/json/json_tracing.h @@ -19,6 +19,7 @@ #include #include +#include namespace Json { class Value; @@ -50,6 +51,7 @@ class JsonBackend : public ::chip::Tracing::Backend void TraceBegin(const char * label, const char * group) override; void TraceEnd(const char * label, const char * group) override; void TraceInstant(const char * label, const char * group) override; + void TraceCounter(const char * label) override; void LogMessageSend(MessageSendInfo &) override; void LogMessageReceived(MessageReceivedInfo &) override; void LogNodeLookup(NodeLookupInfo &) override; @@ -61,6 +63,8 @@ class JsonBackend : public ::chip::Tracing::Backend /// Does the actual write of the value void OutputValue(::Json::Value & value); + std::unordered_map mCounters; + // Output file if writing to a file. If closed, writing // to ChipLog* std::fstream mOutputFile; diff --git a/src/tracing/macros.h b/src/tracing/macros.h index 5f836e44d373bc..b456137b88a166 100644 --- a/src/tracing/macros.h +++ b/src/tracing/macros.h @@ -78,6 +78,7 @@ #define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) +#define MATTER_TRACE_COUNTER(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_LOG_MESSAGE_SEND(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_LOG_MESSAGE_RECEIVED(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) diff --git a/src/tracing/multiplexed/include/matter/tracing/macros_impl.h b/src/tracing/multiplexed/include/matter/tracing/macros_impl.h index e1f2adc56d989e..8b3e728289dc1d 100644 --- a/src/tracing/multiplexed/include/matter/tracing/macros_impl.h +++ b/src/tracing/multiplexed/include/matter/tracing/macros_impl.h @@ -28,6 +28,7 @@ #define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) #define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) #define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) +#define MATTER_TRACE_COUNTER(label) ::chip::Tracing::Internal::Counter(label) namespace chip { namespace Tracing { diff --git a/src/tracing/none/include/matter/tracing/macros_impl.h b/src/tracing/none/include/matter/tracing/macros_impl.h index 3f7f052b5cac0d..3119dce2a2b49f 100644 --- a/src/tracing/none/include/matter/tracing/macros_impl.h +++ b/src/tracing/none/include/matter/tracing/macros_impl.h @@ -31,3 +31,4 @@ #define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) +#define MATTER_TRACE_COUNTER(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) diff --git a/src/tracing/perfetto/include/matter/tracing/macros_impl.h b/src/tracing/perfetto/include/matter/tracing/macros_impl.h index 266ac69f5735a0..9b05d2f3539a45 100644 --- a/src/tracing/perfetto/include/matter/tracing/macros_impl.h +++ b/src/tracing/perfetto/include/matter/tracing/macros_impl.h @@ -30,3 +30,10 @@ PERFETTO_DEFINE_CATEGORIES(perfetto::Category("Matter").SetDescription("Matter t #define MATTER_TRACE_END(label, group) TRACE_EVENT_END("Matter") #define MATTER_TRACE_INSTANT(label, group) TRACE_EVENT_INSTANT("Matter", label, "class_name", group) #define MATTER_TRACE_SCOPE(label, group) TRACE_EVENT("Matter", label, "class_name", group) + +#define MATTER_TRACE_COUNTER(label) \ + do \ + { \ + static int count##_label = 0; \ + TRACE_COUNTER("Matter", label, ++count##_label); \ + } while (0) diff --git a/src/tracing/perfetto/perfetto_tracing.cpp b/src/tracing/perfetto/perfetto_tracing.cpp index 6d89dbbccc9723..b68ec33d33101d 100644 --- a/src/tracing/perfetto/perfetto_tracing.cpp +++ b/src/tracing/perfetto/perfetto_tracing.cpp @@ -21,10 +21,9 @@ #include #include #include -#include - #include #include +#include namespace chip { namespace Tracing { diff --git a/src/tracing/registry.cpp b/src/tracing/registry.cpp index 9f7507aa9f75a6..7c43442b5b83db 100644 --- a/src/tracing/registry.cpp +++ b/src/tracing/registry.cpp @@ -76,6 +76,14 @@ void Instant(const char * label, const char * group) } } +void Counter(const char * label) +{ + for (auto & backend : gTracingBackends) + { + backend.TraceCounter(label); + } +} + void LogMessageSend(::chip::Tracing::MessageSendInfo & info) { for (auto & backend : gTracingBackends) diff --git a/src/tracing/registry.h b/src/tracing/registry.h index 853372585840fa..083ebcb2225ad2 100644 --- a/src/tracing/registry.h +++ b/src/tracing/registry.h @@ -76,6 +76,7 @@ namespace Internal { void Begin(const char * label, const char * group); void End(const char * label, const char * group); void Instant(const char * label, const char * group); +void Counter(const char * label); void LogMessageSend(::chip::Tracing::MessageSendInfo & info); void LogMessageReceived(::chip::Tracing::MessageReceivedInfo & info); diff --git a/src/transport/BUILD.gn b/src/transport/BUILD.gn index 5d1a9c9d3becc0..fa556d40afd5b0 100644 --- a/src/transport/BUILD.gn +++ b/src/transport/BUILD.gn @@ -44,6 +44,7 @@ static_library("transport") { "SessionManager.h", "SessionMessageCounter.h", "SessionMessageDelegate.h", + "SessionUpdateDelegate.h", "TracingStructs.h", "TransportMgr.h", "TransportMgrBase.cpp", @@ -70,7 +71,10 @@ static_library("transport") { ] if (chip_enable_transport_trace) { - sources += [ "TraceMessage.cpp" ] + sources += [ + "TraceMessage.cpp", + "TraceMessage.h", + ] } if (chip_enable_transport_pw_trace) { public_deps += [ "$dir_pw_trace" ] diff --git a/src/transport/Session.h b/src/transport/Session.h index f211a610386bf2..0b6048d5c077c0 100644 --- a/src/transport/Session.h +++ b/src/transport/Session.h @@ -25,8 +25,8 @@ #include #include #include +#include #include -#include #include namespace chip { diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn index 057065a3d1a1bc..18987c6c8c38e9 100644 --- a/src/transport/tests/BUILD.gn +++ b/src/transport/tests/BUILD.gn @@ -19,7 +19,10 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip/chip_test_suite.gni") source_set("helpers") { - sources = [ "LoopbackTransportManager.h" ] + sources = [ + "LoopbackTransportManager.h", + "UDPTransportManager.h", + ] public_deps = [ "${chip_root}/src/transport:transport", diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 3a80deb7f99e33..415f89b4db04fb 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -50,6 +50,9 @@ declare_args() { sl_ot_idle_interval_ms = 15000 # 15s Idle Intervals sl_ot_active_interval_ms = 200 # 200ms Active Intervals + # SSED Specific configurations + sl_ot_csl_timeout_sec = 30 # 30s CSL timeout + # ICD Matter Configuration flags sl_idle_mode_interval_s = 600 # 10min Idle Mode Interval sl_active_mode_interval_ms = 1000 # 1s Active Mode Interval @@ -59,6 +62,9 @@ declare_args() { silabs_log_enabled = true + # Enable Synchronized Sleepy End Device + enable_synchronized_sed = false + # Argument to enable IPv4 for wifi # aligning to match chip_inet_config_enable_ipv4 default configuration chip_enable_wifi_ipv4 = false @@ -160,7 +166,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ieee802154", "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ble", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions", - "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_pti", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init", "${efr32_sdk_root}/platform/service/device_init/inc", @@ -296,13 +301,6 @@ template("efr32_sdk") { #"__STACK_SIZE=0", ] - if (!(use_silabs_thread_lib || use_silabs_thread_lib)) { - #Enabling this config temporarly to fix a build issue until - #official fix is pushed - - defines += [ "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1" ] - } - # Temporary configuration to enable COAP specific configurations if (use_thread_coap_lib) { defines += [ "SL_USE_COAP_CONFIG=1" ] @@ -433,6 +431,14 @@ template("efr32_sdk") { "SL_OT_IDLE_INTERVAL=${sl_ot_idle_interval_ms}", "SL_OT_ACTIVE_INTERVAL=${sl_ot_active_interval_ms}", ] + + if (enable_synchronized_sed) { + defines += [ + "CHIP_DEVICE_CONFIG_THREAD_SSED=1", + "SL_CSL_ENABLE=1", + "SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}", + ] + } } if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) {